예제 #1
0
def __copy_trunk(srcfile, dstfile):
    srcdb = state.open_database(srcfile, False)
    srcsnap = srcdb.get_trunk()

    if resource.os_path_exists(dstfile):
        resource.os_unlink(dstfile)

    dstdb = state.open_database(dstfile, True)
    dstsnap = dstdb.get_trunk()

    copy_snap(srcsnap, dstsnap)
    dstsnap.save(0, '')
    dstdb.flush()
예제 #2
0
def main(manager):

    parser = optparse.OptionParser()
    parser.add_option('--db',
                      action='store',
                      dest='db',
                      default=None,
                      help='db file')
    parser.add_option('--version',
                      action='store',
                      dest='version',
                      default=None,
                      help='version')
    parser.add_option('--target',
                      action='store',
                      dest='target',
                      default='micro',
                      help='target')

    (opts, args) = parser.parse_args(sys.argv)
    args = args[1:]

    if opts.db:
        dbfile = opts.db
    else:
        dbfile = resource.user_resource_file(resource.setup_dir, opts.target)

    db = state.open_database(dbfile, False)

    if opts.version:
        dump_version(db, opts.version, args)
    else:
        dump_versions(db)

    picross.exit(0)
예제 #3
0
파일: bstdump.py 프로젝트: tylerwood/EigenD
def main(manager):
    parser = optparse.OptionParser()
    parser.add_option('--db',
                      action='store',
                      dest='db',
                      default=None,
                      help='db file')
    parser.add_option('--version',
                      action='store',
                      dest='version',
                      default=None,
                      help='version')
    parser.add_option('--target',
                      action='store',
                      dest='target',
                      default='micro',
                      help='target')

    (opts, args) = parser.parse_args(sys.argv)

    if opts.db:
        dbfile = opts.db
    else:
        dbfile = resource.user_resource_file(resource.setup_dir, opts.target)

    db = state.open_database(dbfile, False)

    if opts.version:
        snap = db.get_version(long(opts.version))
    else:
        snap = db.get_trunk()

    dump_snapshot(snap)
예제 #4
0
def get_description_from_file(dbfile):
    try:
        db = state.open_database(dbfile, False)
        snap = db.get_trunk()
        desc = get_description(snap)
        return desc
    except:
        utils.log_exception()
        return ''
예제 #5
0
def upgrade_trunk(src,dst,tweaker=None):
    src_db = state.open_database(src,False)
    src_snap = src_db.get_trunk()
    dst_db = state.open_database(dst,True)
    dst_snap = dst_db.get_trunk()
    copy_snap(src_snap,dst_snap)

    if do_upgrade(dst_snap):
        if tweaker is not None:
            tweaker(dst_snap,src_snap)
        else:
            dst_snap.save(0,'')
        dst_db.flush()
        return True

    try: os.unlink(dst)
    except: pass

    return False
예제 #6
0
def copy_snap2file(srcsnap,dstfile,tweaker=None):
    try: os.unlink(dstfile)
    except: pass
    dstdb = state.open_database(dstfile,True)
    dstsnap = dstdb.get_trunk()
    copy_snap(srcsnap,dstsnap)
    if tweaker is not None:
        tweaker(dstsnap,srcsnap)
    dstsnap.save(0,'')
    dstdb.flush()
    return dstdb.get_trunk()
예제 #7
0
    def edit_setup(self, orig, slot, tag, desc):
        self.savcond.acquire()
        try:
            if self.quitting:
                return
            else:
                self.saving = True
        finally:
            self.savcond.release()

        path = agentd.user_setup_file(slot, tag)

        if orig != path:
            orig_d = os.path.dirname(orig)
            orig_f = os.path.basename(orig)
            path_d = os.path.dirname(path)
            path_f = os.path.basename(path)

            for f in resource.os_listdir(orig_d):
                if f.startswith(orig_f):
                    f2 = os.path.join(path_d, path_f + f[len(orig_f):])
                    resource.os_rename(os.path.join(orig_d, f), f2)

        database = state.open_database(path, True)
        trunk = database.get_trunk()
        upgrade.set_description(trunk, desc)
        trunk.save(piw.tsd_time(), '')
        database.flush()

        self.setups_changed(path)

        self.savcond.acquire()
        try:
            self.saving = False
            self.savcond.notify()
        finally:
            self.savcond.release()

        print 'editing complete', path
        self.info_dialog(
            'Setup Edited', 'Setup Edited',
            "The user setup '" + slot + "' was successfully edited")

        return path
예제 #8
0
def main(manager):
    parser = optparse.OptionParser()
    parser.add_option('--db',
                      action='store',
                      dest='db',
                      default=None,
                      help='db file')
    parser.add_option('--version',
                      action='store',
                      dest='version',
                      default=None,
                      help='version')
    parser.add_option('--target',
                      action='store',
                      dest='target',
                      default='micro',
                      help='target')
    parser.add_option('--dst',
                      action='store',
                      dest='dst',
                      default=None,
                      help='destination')

    (opts, args) = parser.parse_args(sys.argv)

    if opts.db:
        dbfile = opts.db
    else:
        dbfile = resource.user_resource_file(resource.setup_dir, opts.target)

    if not opts.dst:
        parser.error('must specify dst')

    db = state.open_database(dbfile, False)

    if opts.version:
        snap = db.get_version(long(opts.version))
    else:
        snap = db.get_trunk()

    upgrade.copy_snap2file(snap, opts.dst)
예제 #9
0
def prepare_file(srcfile, version):
    dbfile = get_tmp_setup()

    if dbfile != srcfile:
        __copy_trunk(srcfile, dbfile)

    db = state.open_database(dbfile, True)
    snap = db.get_trunk()

    print srcfile, 'version', snap.version()

    srcversion = get_version(snap)

    print 'prepare:', srcversion, 'for', version, 'to', dbfile

    if srcversion != version:
        if not do_upgrade(snap):
            raise RuntimeError('cant upgrade %s' % srcfile)
        set_version(snap, version)
        snap.save(0, 'upgraded to %s' % version)
        db.flush()

    return snap
예제 #10
0
def prepare_file(srcfile,uid,version):
    dbfile = get_tmp_setup()

    if dbfile != srcfile:
        __copy_trunk(srcfile,dbfile)

    db = state.open_database(dbfile,True)
    snap = db.get_trunk()

    print srcfile,'version',snap.version()

    srcuid = get_uid(snap)
    srcversion = get_version(snap)

    print 'prepare:',srcversion,srcuid,'for',version,uid,'to',dbfile

    if srcversion != version:
        if not do_upgrade(snap):
            raise RuntimeError('cant upgrade %s' % srcfile)
        set_version(snap,version)
        snap.save(0,'upgraded to %s' % version)
        db.flush()

    if srcuid and srcuid==uid:
        return snap

    print srcfile,'name adjustment',srcuid,uid

    dstsnap = db.get_trunk()
    map_snap(snap,srcuid,dstsnap,uid)
    set_version(dstsnap,version)
    set_uid(dstsnap,uid)
    dstsnap.save(0,'renaming for %s->%s' % (srcuid,uid))
    db.flush()
    snap = dstsnap

    return snap
예제 #11
0
 def session_main(manager):
     db = state.open_database(args[0], False)
     snap = db.get_trunk()
     sig = upgrade.get_setup_signature(snap, opts.text)
     print sig
     sys.exit(0)