Beispiel #1
0
 def __init__(self, path_db=None):
   if not path_db:
     path_db = config.get_db_path()
   self.conn = lite.connect(path_db)
   self.conn.execute('pragma foreign_keys = on')
   self.conn.commit()
   self.cur = self.conn.cursor()
Beispiel #2
0
def create_rsync_share(name, path, comment, list, readonly, uid, gid):
    try:
        db_path, err = config.get_db_path()
        if err:
            raise Exception(err)

        check, err = db.get_single_row(
            db_path, "select * from rsync_shares where name='%s'" % name)
        if check:
            raise Exception("Share already exists.Use a different share name")

        cmd_list = []
        cmd = [
            "insert into rsync_shares (name,path,comment,list,readonly,uid,gid) values(?,?,?,?,?,?,?)",
            (name, path, comment, list, readonly, uid, gid)
        ]
        cmd_list.append(cmd)
        ret, err = db.execute_iud(db_path, cmd_list)
        if err:
            raise Exception(err)
        conf, err = _generate_rsync_config()
        if err:
            raise Exception(err)
    except Exception, e:
        return False, 'Error saving rsync config settings : %s' % str(e)
Beispiel #3
0
 def get_filepath(self):
     """ Get full filepath of database file | None -> Path """
     folder = config.get_db_path()
     extension = '.pickle'
     filename = self.name + extension
     filepath = folder / filename
     return filepath
Beispiel #4
0
 def __init__(self):
     tk.Tk.__init__(self)
     if not config.get_db_path():
         config.set_db_path()
     if not config.get_backup_path():
         config.set_backup_path()
     if not config.get_session_path():
         config.set_session_path()
     db_type = config.get_db_type()
     if db_type == 'standard':
         db = Databases.StandardDatabase()
     else:
         db = Databases.TranslationDatabase(config.get_lang1(),
                                            config.get_lang2())
     config.active_objects['db'] = db
     config.active_objects[
         'root'] = self  #Allows access outside creation module
     backup.backup()
     self.option_add('*Font',
                     'TkDefaultFont')  #All widgets use default font
     if db_type == 'standard':
         self.main_frame = StandardMainFrame(self)
     else:
         self.main_frame = TranslationMainFrame(self)
     self.menu_bar = MenuBar(self)
     self['menu'] = self.menu_bar
     self.title(config.get_language_dict()['title'])  #Application name
     icon = Image.open('icons/30101621.png')
     icon = ImageTk.PhotoImage(icon)
     self.iconphoto(True, icon)
     self.set_geometry()
     self.bind_events()
Beispiel #5
0
 def __init__(self, path_db=None):
     if not path_db:
         path_db = config.get_db_path()
     self.conn = lite.connect(path_db)
     self.conn.execute('pragma foreign_keys = on')
     self.conn.commit()
     self.cur = self.conn.cursor()
Beispiel #6
0
def load_shares_list():
    l = []
    try:
        db_path, err = config.get_db_path()
        if err:
            raise Exception(err)
        l, err = db.get_multiple_rows(db_path, 'select * from rsync_shares')
        if err:
            raise Exception(err)
    except Exception, e:
        return None, 'Error loading RSYNC shares list : %s' % str(e)
Beispiel #7
0
def get_rsync_share_details(name):
    share = None
    try:
        db_path, err = config.get_db_path()
        if err:
            raise Exception(err)
        share, err = db.get_single_row(
            db_path, "select * from rsync_shares where name='%s'" % name)
        if not share:
            raise Exception("Specified share not found ")
    except Exception, e:
        return False, 'Error deleting the share: %s' % str(e)
Beispiel #8
0
def delete_rsync_share(name):
    try:
        db_path, err = config.get_db_path()
        if err:
            raise Exception(err)
        cmd_list = []
        check, err = db.get_single_row(
            db_path, "select * from rsync_shares where name='%s'" % name)
        if not check:
            raise Exception("Specified share not found ")
        cmd = ["delete from rsync_shares where name='%s'" % name]
        cmd_list.append(cmd)
        ret, err = db.execute_iud(db_path, cmd_list)
        if err:
            raise Exception(err)
        conf, err = _generate_rsync_config()
        if err:
            raise Exception(err)
    except Exception, e:
        return False, 'Error deleting the share: %s' % str(e)
Beispiel #9
0
def get_translation_test_filepath(*args):  #will replace instance method
    folder = config.get_db_path()
    extension = '.pickle'
    filename = 'test_translation_db' + extension
    filepath = folder / filename
    return filepath