Example #1
0
    def run(self):
        """main loop, which executes commands"""
        convert = self._checkVersion() #returns None or current version
        
        self.conn = sqlite3.connect("files.db")
        chmod("files.db", 0600)

        self.c = self.conn.cursor() #compatibility
        
        if convert is not None:
            self._convertDB(convert)
        
        self._createTables()
        self._migrateUser()

        self.conn.commit()
        
        self.setuplock.set()
        
        while True:
            j = self.jobs.get()
            if j == "quit":
                self.c.close()
                self.conn.close()
                break
            j.processJob()
Example #2
0
    def run(self):
        """main loop, which executes commands"""
        convert = self._checkVersion()  #returns None or current version

        # Explicitly clear isolation level, so open transactions are committed
        # before DDL transactions.
        # See: https://github.com/ghaering/pysqlite/issues/109
        self.conn = sqlite3.connect(settings.DATABASE_FILENAME,
                                    isolation_level=None)
        chmod(settings.DATABASE_FILENAME, 0o600)

        self.c = self.conn.cursor()  #compatibility

        if convert is not None:
            self._convertDB(convert)

        self._createTables()
        self._migrateUser()

        self.conn.commit()

        self.setuplock.set()

        while True:
            j = self.jobs.get()
            if j == "quit":
                self.c.close()
                self.conn.close()
                break
            j.processJob()
Example #3
0
 def saveAccounts(self):
     """save all account information"""
     
     f = open("accounts.conf", "wb")
     f.write("version: " + str(ACC_VERSION) + "\n")
             
     for plugin, accounts in self.accounts.iteritems():
         f.write("\n")
         f.write(plugin+":\n")
         
         for name, data in accounts.iteritems():
             f.write("\n\t%s:%s\n" % (name, data['password']) )
             if data['options']:
                 for option, values in data['options'].iteritems():
                     f.write("\t@%s %s\n" % (option, " ".join(values)))
                 
     f.close()
     chmod(f.name, 0600)
Example #4
0
    def saveAccounts(self):
        """save all account information"""

        with open("accounts.conf", "wb") as f:
            f.write(smart_bytes('version: {0}\n'.format(ACC_VERSION)))

            for plugin, accounts in six.iteritems(self.accounts):
                f.write(smart_bytes('\n{0}:\n'.format(plugin)))

                for name, data in six.iteritems(accounts):
                    f.write(
                        smart_bytes('\n\t{0}:{1}\n'.format(
                            name, data['password'])))
                    if data['options']:
                        for option, values in six.iteritems(data['options']):
                            f.write(
                                smart_bytes('\t@{0} {1}\n'.format(
                                    option, b' '.join(values))))

            chmod(f.name, 0o600)