From: <ni...@us...> - 2010-11-10 23:25:30
|
Revision: 102 http://openautomation.svn.sourceforge.net/openautomation/?rev=102&view=rev Author: nilss1 Date: 2010-11-10 23:25:23 +0000 (Wed, 10 Nov 2010) Log Message: ----------- Fix locking on empty datastore.db Modified Paths: -------------- PyWireGate/trunk/WireGate.py PyWireGate/trunk/datastore.py Modified: PyWireGate/trunk/WireGate.py =================================================================== --- PyWireGate/trunk/WireGate.py 2010-11-10 16:20:00 UTC (rev 101) +++ PyWireGate/trunk/WireGate.py 2010-11-10 23:25:23 UTC (rev 102) @@ -147,10 +147,12 @@ getpath = lambda x: "/".join(x.split("/")[:-1]) ##Set Permissions on - os.chown(self.config['WireGate']['pidfile'],runasuser[2],runasuser[3]) - os.chown(self.config['WireGate']['logfile'],runasuser[2],runasuser[3]) - os.chown(self.config['WireGate']['datastore'],runasuser[2],runasuser[3]) + for sysfile in [self.config['WireGate']['pidfile'],self.config['WireGate']['logfile'],self.config['WireGate']['datastore']]: + if not os.path.exists(sysfile): + open(sysfile,'w').close() + os.chown(sysfile,runasuser[2],runasuser[3]) + ##removed until fixing permissions #os.setregid(runasuser[3],runasuser[3]) #os.setreuid(runasuser[2],runasuser[2]) Modified: PyWireGate/trunk/datastore.py =================================================================== --- PyWireGate/trunk/datastore.py 2010-11-10 16:20:00 UTC (rev 101) +++ PyWireGate/trunk/datastore.py 2010-11-10 23:25:23 UTC (rev 102) @@ -111,16 +111,19 @@ self.dataobjects[name].config = obj['config'] self.dataobjects[name].connected = obj['connected'] self.debug("%d entries loaded in DATASTORE" % len(self.dataobjects)) - self.locked.release() self.DBLOADED = True except IOError: ## no DB File pass - + except ValueError: + ## empty DB File + self.DBLOADED = True + pass except: self.WG.errorlog() ## error pass + self.locked.release() def save(self): @@ -167,10 +170,10 @@ def shutdown(self): self.cycleThreadLock.acquire() - for obj in self.cycleThreads: + for obj in self.cycleThreads.keys(): try: - obj.cancel() - obj.join() + self.cycleThreads[obj].cancel() + self.cycleThreads[obj].join() except: pass self.cycleThreadLock.release() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |