Пример #1
0
def check_and_setup():
    try: os.mkdir(config.mdb_dir)
    except OSError, e: pass

    try: os.mkdir(config.images_folder)
    except OSError, e: pass

    if (os.path.exists(config.db_file) and \
            config.config['db_version'] < config.db_version):
        # db_version is old, make new db file
        os.unlink(config.db_file)

    if (not os.path.exists(config.db_file)):
        create_db = True
    else:
        create_db = False

    conn = sqlite3.connect(config.db_file)
    conn.row_factory = sqlite3.Row
    cur = conn.cursor()

    if (create_db):
        create_database(conn, cur)

        config.config['db_version'] = config.db_version
        config.config.write()
        config.post_process()

    return conn, cur
Пример #2
0
    def check_for_updates(self):
        time_to_cmp = (config.config['update_last_checked'] +
            (config.config['upd_freq'] * 24 * 3600))
        if (self.force or (int(time.time()) > time_to_cmp)):
            try:
                upd_data = requests.get(config.update_url)
            except requests.RequestException, e:
                print "RequestException", e
                if (self.force):
                    evt = wx_signal.ShowMsgEvent(wx_signal.myEVT_SHOW_MSG, -1,
                            config.cant_connect_content)
                    wx.PostEvent(self.parent, evt)
                # FIXME Back off for some time  or check after 7 days?
                return

            if (upd_data.ok and 'version' in upd_data.json and\
                    upd_data.json['version'] > config.version):
                # FIXME make sure versions can be compared as strings!
                print "valid update found"
                self.show_upd_dialog(upd_data.json)
            else:
                print 'no updates'
                # report no updates
                if (self.force):
                    evt = wx_signal.ShowMsgEvent(wx_signal.myEVT_SHOW_MSG, -1,
                            config.no_updates_content)
                    wx.PostEvent(self.parent, evt)

            config.config['update_last_checked'] = int(time.time())
            config.config.write()
            config.post_process()
Пример #3
0
    def on_ok(self, evt):
        for item in self.items_map:
            name = item[0]
            config.config[name] = self.controls_map[name].GetValue()

        config.config.write()
        config.post_process()
        self.Destroy()
Пример #4
0
def main():
    args = docopt(__doc__, version=__version__)
    try:
        config.validate()
        config.post_process()

        _parse_user_input(args)
    except KeyboardInterrupt:
        pass
    except BaseMimironException as e:
        io.err(e)
        exit(1)
    exit(0)