create daemon db table if it doesn't exist
This commit is contained in:
parent
65ea5cf6f0
commit
6fd0f9aded
@ -371,20 +371,19 @@ class Core:
|
|||||||
'''
|
'''
|
||||||
retData = False
|
retData = False
|
||||||
if not os.path.exists(self.queueDB):
|
if not os.path.exists(self.queueDB):
|
||||||
conn = sqlite3.connect(self.queueDB)
|
self.makeDaemonDB()
|
||||||
c = conn.cursor()
|
|
||||||
# Create table
|
|
||||||
c.execute('''CREATE TABLE commands
|
|
||||||
(id integer primary key autoincrement, command text, data text, date text)''')
|
|
||||||
conn.commit()
|
|
||||||
else:
|
else:
|
||||||
conn = sqlite3.connect(self.queueDB)
|
conn = sqlite3.connect(self.queueDB)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
for row in c.execute('SELECT command, data, date, min(ID) FROM commands group by id'):
|
try:
|
||||||
retData = row
|
for row in c.execute('SELECT command, data, date, min(ID) FROM commands group by id'):
|
||||||
break
|
retData = row
|
||||||
if retData != False:
|
break
|
||||||
c.execute('DELETE FROM commands WHERE id=?;', (retData[3],))
|
except sqlite3.OperationalError:
|
||||||
|
self.makeDaemonDB()
|
||||||
|
else:
|
||||||
|
if retData != False:
|
||||||
|
c.execute('DELETE FROM commands WHERE id=?;', (retData[3],))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@ -392,6 +391,16 @@ class Core:
|
|||||||
|
|
||||||
return retData
|
return retData
|
||||||
|
|
||||||
|
def makeDaemonDB(self):
|
||||||
|
'''generate the daemon queue db'''
|
||||||
|
conn = sqlite3.connect(self.queueDB)
|
||||||
|
c = conn.cursor()
|
||||||
|
# Create table
|
||||||
|
c.execute('''CREATE TABLE commands
|
||||||
|
(id integer primary key autoincrement, command text, data text, date text)''')
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
def daemonQueueAdd(self, command, data=''):
|
def daemonQueueAdd(self, command, data=''):
|
||||||
'''
|
'''
|
||||||
Add a command to the daemon queue, used by the communication daemon (communicator.py)
|
Add a command to the daemon queue, used by the communication daemon (communicator.py)
|
||||||
|
Loading…
Reference in New Issue
Block a user