[web2py] Re: Traceback with record versioning enabled and common_filter defined.
On Saturday, 10 January 2015 13:15:48 UTC, Paolo Valleri wrote: Hi, I've fixed the error but I've to understand if all common_filters are applied correctly. Do you mind to test https://github.com/ilvalle/web2py/tree/issue-2023 ? Ok, will add some more common filters and get onto testing it asap. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Traceback with record versioning enabled and common_filter defined.
I created a PR https://github.com/web2py/web2py/pull/585 Paolo 2015-01-10 17:31 GMT+01:00 Jose C houdinihoun...@gmail.com: Do you mind to test https://github.com/ilvalle/web2py/tree/issue-2023 ? Ok Paolo, it all appears to work as expected now with trunk (2.9.12 beta) - at least with my current system and setup. I also backported your change to my dev version (2.9.5) and it too works. Many thanks for fixing this bug so quickly. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/mohm6Nb8Mfc/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Traceback with record versioning enabled and common_filter defined.
Do you mind to test https://github.com/ilvalle/web2py/tree/issue-2023 ? Ok Paolo, it all appears to work as expected now with trunk (2.9.12 beta) - at least with my current system and setup. I also backported your change to my dev version (2.9.5) and it too works. Many thanks for fixing this bug so quickly. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Traceback with record versioning enabled and common_filter defined.
uhmbut record_versioning adds a common_filter per se, and is usually on the form of is_active == True. Did you try to set a different common_filter ? On Saturday, January 10, 2015 at 8:58:21 AM UTC+1, Jose C wrote: Bug reported: https://code.google.com/p/web2py/issues/detail?id=2032can=4 -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Traceback with record versioning enabled and common_filter defined.
On Saturday, 10 January 2015 12:20:31 UTC, Niphlod wrote: uhmbut record_versioning adds a common_filter per se, and is usually on the form of is_active == True. Did you try to set a different common_filter ? Yes I tried various, within the table definition and external to it (post definition). I used that one as the simplest example (probably not the best). But even so, all it should do is create a query with the 2 statements (even though they are the same condition). Something like (WHERE fld == True AND fld == True). Redundant, sure... but shouldn't cause a traceback. I looked into the dal.py code where it happens and that line is trying to `` two lambda functions (hence the traceback error message). From my understanding it should be trying to `` two query objects, not functions. I did try converting to queries, applying the operator and then converting back to function, but that broke something else down line in record versioning for reasons I haven't figured out yet. So no solution yet. Will post to the bug report if I get it to work. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Traceback with record versioning enabled and common_filter defined.
Hi, I've fixed the error but I've to understand if all common_filters are applied correctly. Do you mind to test https://github.com/ilvalle/web2py/tree/issue-2023 ? Paolo On Saturday, January 10, 2015 at 2:01:56 PM UTC+1, Jose C wrote: On Saturday, 10 January 2015 12:20:31 UTC, Niphlod wrote: uhmbut record_versioning adds a common_filter per se, and is usually on the form of is_active == True. Did you try to set a different common_filter ? Yes I tried various, within the table definition and external to it (post definition). I used that one as the simplest example (probably not the best). But even so, all it should do is create a query with the 2 statements (even though they are the same condition). Something like (WHERE fld == True AND fld == True). Redundant, sure... but shouldn't cause a traceback. I looked into the code where it happens and that line is trying to `` two lambda functions (hence the traceback error message). From my understanding it should be trying to `` two query objects, not functions. I did try converting to queries, applying the operator and then converting back to function, but that broke something else down line in record versioning for reasons I haven't figured out yet. So no solution yet. Will post to the bug report if I get it to work. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] SQLFORM in Nested components
I have a form in nested components created by response.js's Create placeholders per topic for t in topics: url = URL('environment', 'issues_per_topic.load', vars=dict(topic=t.id, mgt_sys=S4)) response.js += $.web2py.component('%s','s4_topic_%s'); % (url, t.id) url = URL('environment', 'issues_per_topic.load', vars=dict(topic=t.id, mgt_sys=S3)) response.js += $.web2py.component('%s','s3_topic_%s'); % (url, t.id) fill placeholders with issues for i in issues: url = URL('environment', 'view_issue.load', vars=dict(issue_id=i.id)) response.js += $.web2py.component('%s', 'chg_issue_%s'); % (url, i.id) Call SQLFORM for editting the record {{=A(T(Edit),_href=URL('environment','change_issue.load', vars=dict(issue_id=i.id)), ajax=True, cid='chg_issue_' + str(i.id), _class='label') }} The submit button (=ajax?) is not working on this latter FORM. What is wrong here? Richard D -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Graphviz web2py not found
you need to install pygraphviz to have graphs On Saturday, January 10, 2015 at 4:15:32 PM UTC+1, Raphael Viana wrote: Hello everyone, I started very recently in web2py world, but i have a problem. when i use a graph model web2py return for me a error message graphviz library not found OBS: I'm using a web2py source code, and i set the variable on environment variable system. I use Windows 8.1 pro. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] [solved] Weird type 'exceptions.AttributeError' 'Row' object has no attribute 'id' and Ñ error
Hi, just for other developers sake to save some time. I was getting this error: type 'exceptions.AttributeError' 'Row' object has no attribute 'id' Versión web2py™ Version 2.9.11-stable+timestamp.2014.09.15.23.35.11 Traceback (most recent call last): File ./web2py/gluon/restricted.py, line 224, in restricted exec ccode in environment File ./web2py/applications/AlcalaFyE/controllers/appadmin.py, line 671, in module File ./web2py/gluon/globals.py, line 392, in lambda self._caller = lambda f: f() File ./web2py/applications/AlcalaFyE/controllers/appadmin.py, line 341, in update f='download', args=request.args[:1])) File ./web2py/gluon/sqlhtml.py, line 1168, in __init__ self.record_id = str(record[field.name]) File ./web2py/gluon/dal.py, line 7529, in __getitem__ raise ae AttributeError: 'Row' object has no attribute 'id' It was quite confusing because I could create records (with appadmin or smartgrid), and see them in a grid, and the problem only appeared when I tried to view the record in a form. I do NEVER use international characters in field names, but as I am spanish, unintentionally wrote a Ñ character (U+00D1: N with a diacritical tilde) in a field name. As soon as I replaced the Ñ with a N, everything worked fine. I'm quite a new user of web2py, and as I'm dealing with the ins and outs of web2py, I repeatedly skipped such an obvious question and was looking for a more subtle error. As I couldn't find any reference to this problem in the forum, I thought I would make sense to report it. I think web2py is a great product. Good job! Best regards. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Having trouble accessing db from a Thread executed within a module.
Currently I am new to programming and I thought Python and web2py would be a good way to learn. But, I am in it over my head when it comes to this problem. I'm getting an error when trying to access a db connection inside a Thread which is contained inside a module. The most pertinent part of the error is this. if not self.connection: raise ValueError(a[0]) Here are the related pieces of code which are causing the problem. I've tried setting the value of db using a method inside coffee_server_threadR6. I have tried every way I can think of to get db into the module.(including current) and unfortunately once the tread is initialized I can't retrieve or set any data from my database. The only thing that does work is seeing which tables, and columns exist. So, it's as though once the variable db gets placed into the thread it no longer has a connection to the database at all. Any thoughts on this are appreciated. Models - db.py db = DAL('sqlite://storage.sqlite',pool_size=2,check_reserved=['all'], do_connect=True) Controllers - default @auth.requires_login() def startserv(): Server.ThreadedTCPRequestHandler.db = db reactor = Server.Reactor() reactor.daemon = True reactor.start() return redirect(URL('index')) Modules - coffee_server_threadR6.py #!/usr/bin/env python # -*- coding: utf-8 -*- from gluon import * from gluon import current import threading import time import SocketServer import struct import binascii from subprocess import Popen import databaseTest as Db_Conn SEND_WAKEUP = chr(1) AM_AWAKE = chr(0) class ThreadedTCPRequestHandler(SocketServer.StreamRequestHandler): cur_thread = threading.current_thread() db = None def wakeup_computer(self,mac): Popen(['echo', str(mac)]) time.sleep(3) Popen(['echo', str(mac)]) def handle(self): recv_data = self.request.recv(1024) packed_data = binascii.unhexlify(recv_data) s = struct.Struct('c 17s') self.unpacked_data = s.unpack(packed_data) self.macAddr = str(self.unpacked_data[1]) self.command = self.unpacked_data[0] response = {}: {}.format(self.cur_thread.name, self.macAddr) self.request.sendall(response) self.updateDB(self.macAddr) def updateDB(self,mac): print self.db.computerstats.fields print self.db.computerstats.mac_addr.type print type(mac) comp = self.db(self.db.computerstats.id==1).select().first() print comp self.db(self.db.computerstats.mac_addr==mac).update(status=1) self.db.commit() #self.db(self.db.computerstats.mac_addr=='AA:BB:CC:DD:EE:FF').update(status=True) class ThreadedTCPServer(SocketServer.ThreadingTCPServer): pass class CountThread(threading.Thread): def run(self): global TOTAL for i in range(100): TOTAL = TOTAL + 1 print('%s\n' % (TOTAL)) class Reactor(threading.Thread): def run(self): self.HOST, self.PORT = '', 8585 SocketServer.TCPServer.allow_reuse_address = True self.server = ThreadedTCPServer((self.HOST, self.PORT), ThreadedTCPRequestHandler) print Server is set up self.server.serve_forever() coffee_client.py - Executed from another computer. Currently testing from local machine. from socket import * import struct import binascii SEND_WAKEUP = chr(1) AM_AWAKE = chr(0) def send(data): sock = socket(AF_INET,SOCK_STREAM) sock.connect(('127.0.0.1',8585)) try: sock.send(data) response = sock.recv(1024) print Received: {}.format(response) finally: sock.close() def wakeup(mac): values = (SEND_WAKEUP, mac) s = struct.Struct('c 17s') packed_data = s.pack(*values) hex_packed_data = binascii.hexlify(packed_data) send(hex_packed_data) def am_awake(mac): values = (AM_AWAKE, mac) s = struct.Struct('c 17s') packed_data = s.pack(*values) hex_packed_data = binascii.hexlify(packed_data) send(hex_packed_data) am_awake('AA:BB:CC:DD:EE:FF') -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] How to access a field value from its object?
I have a table with many different kinds of fields: db.define_table('sounder', Field('part_nr','string',label='Part Number'), Field('current_mA','double',label='Current mA',comment='max current at rated voltage'), Field('current_notes','string',label='Current Measurement Conditions',comment='e.g. current was measured at 12V (DC) or at 4.1kHz and 5 Vpp'), Field('spl','double',label='Sound Pressure Level dB at 30cm'), etc etc I would like to make a html table just like a datasheet. So In my controller: a_field=[] field_header=TR(TH('Characteristic'),TH('Typical'),TH('Comments')) for f in db.sounder: a_field.append([ f.label ,* f *, f.comment ]) In my view (say) {{=TABLE(THEAD(field_header), TBODY( a_field[0], a_field[1], a_field[2], etc etc ),_class=table table-bordered)}} But you see, I need the middle column *(in red above)* to be the actual value of the field. The above does not give this. How can I get the actual value of the field from its object? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Problem using grid after crud
https://lh4.googleusercontent.com/-oiNvwgidljw/VLEEKGeyu4I/C2I/QUCMxdozIxI/s1600/%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%2B%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%2B%D0%BE%D1%82%2B2015-01-10%2B13%3A48%3A57.png https://lh4.googleusercontent.com/-oiNvwgidljw/VLEEKGeyu4I/C2I/QUCMxdozIxI/s1600/%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%2B%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%2B%D0%BE%D1%82%2B2015-01-10%2B13%3A48%3A57.png -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Launched a web2py beta page
Hi, everybody. There was a thread in this group (originally posted by Massimo, if I'm not mistaken), which compiled a list of the group's users' web2py projects. I can't seem to track down that thread, so I made this one to present http://pollfix.com, a web2py-based page that our little team just launched. The page is currently in a sort of beta mode, and we'd welcome any comments, suggestions, bug notifications, and so on that you guys would like to send us. If it's anything regarding security, or something that's better kept private, please send a private message. Also, we'd like to thank everyone involved in web2py's development and documentation, and everyone contributing helpful comments and providing assistance in this google group! The framework is great, and the community really facilitates the development process. Thank you! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Not getting expected results from a query
Thanks for the help, got it working. I need to learn some debugging techniques for web2py, but you have pointed me in the right direction for this kind of problem, if anyone has any suggested links it would be appreciated, thanks! On Friday, January 9, 2015 at 1:15:13 AM UTC-7, Niphlod wrote: then do a def cost3(): jnum = request.args(0,cast=int) a = 0 thequery = db(db.PO.job_id==jnum)._select() results = db(db.PO.job_id==jnum).select() for row in results: a = a + row.mycost return dict(a=a, howmany=len(results), thequery=thequery) too see if the underlying t-sql is correct. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Graphviz web2py not found
Hello everyone, I started very recently in web2py world, but i have a problem. when i use a graph model web2py return for me a error message graphviz library not found OBS: I'm using a web2py source code, and i set the variable on environment variable system. I use Windows 8.1 pro. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Having trouble accessing db from a Thread executed within a module.
You should not create threads from insider a web applications. Not in web2py. Not in any other web framework. This is because threads are managed by the web server which spawns a new one when an http request arrives and kills them they they are completed or timeout. This logic is outside of your control and will conflict with your threads. depending on the web server you use, it may actually use processes instead of threads and it may decide a kill a process with all its threads. This is why web2py has a scheduler. On Saturday, 10 January 2015 10:32:41 UTC-6, Michael Sounhein wrote: Currently I am new to programming and I thought Python and web2py would be a good way to learn. But, I am in it over my head when it comes to this problem. I'm getting an error when trying to access a db connection inside a Thread which is contained inside a module. The most pertinent part of the error is this. if not self.connection: raise ValueError(a[0]) Here are the related pieces of code which are causing the problem. I've tried setting the value of db using a method inside coffee_server_threadR6. I have tried every way I can think of to get db into the module.(including current) and unfortunately once the tread is initialized I can't retrieve or set any data from my database. The only thing that does work is seeing which tables, and columns exist. So, it's as though once the variable db gets placed into the thread it no longer has a connection to the database at all. Any thoughts on this are appreciated. Models - db.py db = DAL('sqlite://storage.sqlite',pool_size=2,check_reserved=['all'], do_connect=True) Controllers - default @auth.requires_login() def startserv(): Server.ThreadedTCPRequestHandler.db = db reactor = Server.Reactor() reactor.daemon = True reactor.start() return redirect(URL('index')) Modules - coffee_server_threadR6.py #!/usr/bin/env python # -*- coding: utf-8 -*- from gluon import * from gluon import current import threading import time import SocketServer import struct import binascii from subprocess import Popen import databaseTest as Db_Conn SEND_WAKEUP = chr(1) AM_AWAKE = chr(0) class ThreadedTCPRequestHandler(SocketServer.StreamRequestHandler): cur_thread = threading.current_thread() db = None def wakeup_computer(self,mac): Popen(['echo', str(mac)]) time.sleep(3) Popen(['echo', str(mac)]) def handle(self): recv_data = self.request.recv(1024) packed_data = binascii.unhexlify(recv_data) s = struct.Struct('c 17s') self.unpacked_data = s.unpack(packed_data) self.macAddr = str(self.unpacked_data[1]) self.command = self.unpacked_data[0] response = {}: {}.format(self.cur_thread.name, self.macAddr) self.request.sendall(response) self.updateDB(self.macAddr) def updateDB(self,mac): print self.db.computerstats.fields print self.db.computerstats.mac_addr.type print type(mac) comp = self.db(self.db.computerstats.id==1).select().first() print comp self.db(self.db.computerstats.mac_addr==mac).update(status=1) self.db.commit() #self.db(self.db.computerstats.mac_addr=='AA:BB:CC:DD:EE:FF').update(status=True) class ThreadedTCPServer(SocketServer.ThreadingTCPServer): pass class CountThread(threading.Thread): def run(self): global TOTAL for i in range(100): TOTAL = TOTAL + 1 print('%s\n' % (TOTAL)) class Reactor(threading.Thread): def run(self): self.HOST, self.PORT = '', 8585 SocketServer.TCPServer.allow_reuse_address = True self.server = ThreadedTCPServer((self.HOST, self.PORT), ThreadedTCPRequestHandler) print Server is set up self.server.serve_forever() coffee_client.py - Executed from another computer. Currently testing from local machine. from socket import * import struct import binascii SEND_WAKEUP = chr(1) AM_AWAKE = chr(0) def send(data): sock = socket(AF_INET,SOCK_STREAM) sock.connect(('127.0.0.1',8585)) try: sock.send(data) response = sock.recv(1024) print Received: {}.format(response) finally: sock.close() def wakeup(mac): values = (SEND_WAKEUP, mac) s = struct.Struct('c 17s') packed_data = s.pack(*values) hex_packed_data = binascii.hexlify(packed_data) send(hex_packed_data) def am_awake(mac): values = (AM_AWAKE, mac) s = struct.Struct('c 17s') packed_data = s.pack(*values) hex_packed_data = binascii.hexlify(packed_data) send(hex_packed_data) am_awake('AA:BB:CC:DD:EE:FF') -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You
[web2py] Re: cron job not running at all
For something like that you have to use the unix cron. The web2py cron is only for python tasks. Anyway, cron is deprecated now that we have the scheduler. On Wednesday, 7 January 2015 18:51:48 UTC-6, SHAO MIN wrote: Hello there! I'm also having problem with my cron job.Basically i need to set a command to let the system auto run every 1 mintue but when i try to place the code inside the crontab -e it doesn't work. the command that i need to run is : pscp root @192.168.7.2:/home/debian/Desktop/SensorData/Sensor,txt /home/student/Desktop/sensordata therefore in the crontab -e to run every 1 minute i wrote : */1 * * * * /pscp root @192.168.7.2:/home/debian/Desktop/SensorData/Sensor,txt /home/student/Desktop/sensordata but it doesn't work. Can anybody help? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Having trouble accessing db from a Thread executed within a module.
Thanks, that's good to know. I'll look into the scheduler. On Saturday, January 10, 2015 at 7:54:39 PM UTC-6, Massimo Di Pierro wrote: You should not create threads from insider a web applications. Not in web2py. Not in any other web framework. This is because threads are managed by the web server which spawns a new one when an http request arrives and kills them they they are completed or timeout. This logic is outside of your control and will conflict with your threads. depending on the web server you use, it may actually use processes instead of threads and it may decide a kill a process with all its threads. This is why web2py has a scheduler. On Saturday, 10 January 2015 10:32:41 UTC-6, Michael Sounhein wrote: Currently I am new to programming and I thought Python and web2py would be a good way to learn. But, I am in it over my head when it comes to this problem. I'm getting an error when trying to access a db connection inside a Thread which is contained inside a module. The most pertinent part of the error is this. if not self.connection: raise ValueError(a[0]) Here are the related pieces of code which are causing the problem. I've tried setting the value of db using a method inside coffee_server_threadR6. I have tried every way I can think of to get db into the module.(including current) and unfortunately once the tread is initialized I can't retrieve or set any data from my database. The only thing that does work is seeing which tables, and columns exist. So, it's as though once the variable db gets placed into the thread it no longer has a connection to the database at all. Any thoughts on this are appreciated. Models - db.py db = DAL('sqlite://storage.sqlite',pool_size=2,check_reserved=['all'], do_connect=True) Controllers - default @auth.requires_login() def startserv(): Server.ThreadedTCPRequestHandler.db = db reactor = Server.Reactor() reactor.daemon = True reactor.start() return redirect(URL('index')) Modules - coffee_server_threadR6.py #!/usr/bin/env python # -*- coding: utf-8 -*- from gluon import * from gluon import current import threading import time import SocketServer import struct import binascii from subprocess import Popen import databaseTest as Db_Conn SEND_WAKEUP = chr(1) AM_AWAKE = chr(0) class ThreadedTCPRequestHandler(SocketServer.StreamRequestHandler): cur_thread = threading.current_thread() db = None def wakeup_computer(self,mac): Popen(['echo', str(mac)]) time.sleep(3) Popen(['echo', str(mac)]) def handle(self): recv_data = self.request.recv(1024) packed_data = binascii.unhexlify(recv_data) s = struct.Struct('c 17s') self.unpacked_data = s.unpack(packed_data) self.macAddr = str(self.unpacked_data[1]) self.command = self.unpacked_data[0] response = {}: {}.format(self.cur_thread.name, self.macAddr) self.request.sendall(response) self.updateDB(self.macAddr) def updateDB(self,mac): print self.db.computerstats.fields print self.db.computerstats.mac_addr.type print type(mac) comp = self.db(self.db.computerstats.id==1).select().first() print comp self.db(self.db.computerstats.mac_addr==mac).update(status=1) self.db.commit() #self.db(self.db.computerstats.mac_addr=='AA:BB:CC:DD:EE:FF').update(status=True) class ThreadedTCPServer(SocketServer.ThreadingTCPServer): pass class CountThread(threading.Thread): def run(self): global TOTAL for i in range(100): TOTAL = TOTAL + 1 print('%s\n' % (TOTAL)) class Reactor(threading.Thread): def run(self): self.HOST, self.PORT = '', 8585 SocketServer.TCPServer.allow_reuse_address = True self.server = ThreadedTCPServer((self.HOST, self.PORT), ThreadedTCPRequestHandler) print Server is set up self.server.serve_forever() coffee_client.py - Executed from another computer. Currently testing from local machine. from socket import * import struct import binascii SEND_WAKEUP = chr(1) AM_AWAKE = chr(0) def send(data): sock = socket(AF_INET,SOCK_STREAM) sock.connect(('127.0.0.1',8585)) try: sock.send(data) response = sock.recv(1024) print Received: {}.format(response) finally: sock.close() def wakeup(mac): values = (SEND_WAKEUP, mac) s = struct.Struct('c 17s') packed_data = s.pack(*values) hex_packed_data = binascii.hexlify(packed_data) send(hex_packed_data) def am_awake(mac): values = (AM_AWAKE, mac) s = struct.Struct('c 17s') packed_data = s.pack(*values) hex_packed_data = binascii.hexlify(packed_data) send(hex_packed_data) am_awake('AA:BB:CC:DD:EE:FF') -- Resources: - http://web2py.com -
[web2py] Re: How to access a field value from its object?
In your table each row is a field but which record should this correspond to? given a record you can do record = db.sounder[some_record_id] a_field=[] field_header=TR(TH('Characteristic'),TH('Typical'),TH('Comments')) for f in db.sounder: a_field.append([ f.label ,* record[f.name] *, f.comment ]) On Friday, 9 January 2015 22:18:16 UTC-6, Ben Lawrence wrote: I have a table with many different kinds of fields: db.define_table('sounder', Field('part_nr','string',label='Part Number'), Field('current_mA','double',label='Current mA',comment='max current at rated voltage'), Field('current_notes','string',label='Current Measurement Conditions',comment='e.g. current was measured at 12V (DC) or at 4.1kHz and 5 Vpp'), Field('spl','double',label='Sound Pressure Level dB at 30cm'), etc etc I would like to make a html table just like a datasheet. So In my controller: a_field=[] field_header=TR(TH('Characteristic'),TH('Typical'),TH('Comments')) for f in db.sounder: a_field.append([ f.label ,* f *, f.comment ]) In my view (say) {{=TABLE(THEAD(field_header), TBODY( a_field[0], a_field[1], a_field[2], etc etc ),_class=table table-bordered)}} But you see, I need the middle column *(in red above)* to be the actual value of the field. The above does not give this. How can I get the actual value of the field from its object? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: In search of CAS 2 provider and consumer example
For what it is worth we have integrated a web2py app to two different external cas providers both in http and https with no problem including ssls with ssl3.0 disabled in favor of tls. Anyone working on a shib sso? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Login to web2py from external script
Do you happen to have made a script that can login to web2py? It looks quite complex because have to manage the _formkey and login form uses multipart/form-data instead of application/x-www-form-urlencoded. I have this working solution using mechanize: br = mechanize.Browser() br.open(login_url) br.select_form(nr=0) br['email'] = email br['password'] = password response = br.submit() But looking for something using urllib2, and not loading a web2py specific library. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.