Exemple #1
0
def update_timestamp():
    db = sqlite3.connect(config.SS_HOME_DIR + "/simplecd/verycd.sqlite3.db")
    db.text_factory = str
    c = db.cursor()
    c.execute("select updtime from verycd order by updtime desc")
    updtime = c.fetchone()[0]
    c.close()
    config.SS_DB_UPDTIME = str(int(time.mktime(time.strptime(updtime, "%Y/%m/%d %H:%M:%S"))))
    config.savecfg()
Exemple #2
0
def update_db_updtime(id):
    try:
        url = config.SS_UPDATE_URL + "/Updtime." + str(id)
        updtime = urllib2.urlopen(url).read()
        if not updtime.startswith("error"):
            config.SS_DB_UPDTIME = urllib2.urlopen(url).read()
            config.savecfg()
            return "ok"
    except Exception as what:
        return "error: " + what.__str__()
Exemple #3
0
 def onOK(self,event):
     config.SS_PORT = self.textCtrl_port.GetValue()
     try:
         config.SS_DB_UPDTIME = str(int(time.mktime(time.strptime(self.textCtrl_updt.GetValue(),'%Y/%m/%d %H:%M:%S'))))
     except Exception as what:
         print what.__str__()
     config.SS_MAX_THREADS = self.textCtrl_mt.GetValue()
     config.SS_UPDATE_SOURCE = self.rb2.GetValue() and 'verycd' or 'simplecd'
     config.savecfg()
     self.Close()
Exemple #4
0
def changecfg(cmd, flg, opt, par, arg):
    if 'h' in flg or 'help' in opt:
        return '''usage: set [-a|--add] [-l|--local] [<key> <value>|-<key>=<value>]
keys: 
version - current active game version
manual - whether to decide mod version manually'''
    addflg = 'a' in flg or 'add' in opt
    locflg = 'l' in flg or 'local' in opt
    for k, v in par.items():
        if k in ('v', 'ver', 'version'):
            key = 'v'
            val = v
            break
        elif k in ('m', 'man', 'manual', 'manual_version'):
            key = 'm'
            val = v
            break
    else:
        if len(arg) == 2:
            if k in ('v', 'ver', 'version'):
                key = 'v'
                val = v
            elif k in ('m', 'man', 'manual', 'manual_version'):
                key = 'm'
                val = v
            else:
                return 'key not specified'
        else:
            return 'exactly one pair of key-value required'
    if k == 'v':
        if addflg or v.strip() == '' or v in dircfg['versions'].keys():
            dircfg['curver'] = v
            savecfg(dircfg, curdircfg)
        else:
            return 'version not exist. use [-a|--add] to add one, or choose from below:\n' + '\n'.join(
                dircfg.keys
            ) + '\n\nYou may use \' \'(a space) for common version'
    elif k == 'm':
        if v.lower() in ('true', 't', 'y', 'yes', 'on'):
            v = True
        elif v.lower in ('false', 'f', 'n', 'no', 'off'):
            v = False
        else:
            return 'usage: set manual [-l|--local] (on|off)'
        if locflg:
            dircfg['manual_version'] = v
        else:
            cfg['manual_version'] = v
        manual_version = dircfg.get('manual_version', cfg['manual_version'])
    else:
        'Something Bad Happened'
Exemple #5
0
def cd(cmd, flg, opt, par, arg):
    if 'h' in flg or 'help' in opt or len(arg) != 1:
        return '''usage: cd <path_to_'.minecraft'>'''
    tmp = newdir(arg[0])
    savecfg()
    return tmp
Exemple #6
0
~~~~~~~~~~~~~~~~~~~~~

WIP
"""

from curse import *
from config import cfg, savecfg, newdir, cfginit
from arg import parse

#find curdir
if cfg['curdir']:
    curdir = cfg['curdir']
#add if no curdir
else:
    curdir = newdir(input('add a directory>'))
    savecfg()

if not curdir:
    print('no current dir!')
    exit()

curdircfg = curdir + 'mmm.json'
dircfg = cfginit(
    curdircfg, {
        'versions': {
            ' (common version) ': {
                'dir': 'mods/',
                'content': [],
                'state': 'Done',
                'pending': [],
                'versions': []