Пример #1
0
 def rpc_reset_test_data(self,arg):
     print 'reset test data'
     try:
         resource.os_unlink(self.__filename)
     except:
         pass
     self.audio.reset_dropout_count()
Пример #2
0
def clr_tmp_setup():
    dbdir = resource.user_resource_dir(resource.setup_dir)
    for g in resource.glob_glob(os.path.join(dbdir, 'tmpsetup*')):
        try:
            resource.os_unlink(g)
            print 'delete', g
        except:
            pass
Пример #3
0
 def rename(self,cookie,name):
     n = '%s.name' % name.replace(' ','_')
     path = os.path.join(self.userdir,n)
     try: resource.os_unlink(path)
     except: pass
     f = resource.file_open(path,'w')
     f.write(cookie)
     f.close()
     self.__update()
     return action.nosync_return()
Пример #4
0
def copy_snap2file(srcsnap, dstfile, tweaker=None):
    try:
        resource.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()
Пример #5
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()
Пример #6
0
    def save_rename(self, root, prefix, final):
        root_d = os.path.dirname(root)
        root_f = prefix + os.path.basename(root)
        prefix_len = len(prefix)

        for f in resource.os_listdir(root_d):
            if f.startswith(root_f):
                f2 = os.path.join(root_d, f[prefix_len:])
                try:
                    resource.os_unlink(f2)
                except:
                    pass
                resource.os_rename(os.path.join(root_d, f), f2)
Пример #7
0
def send_one_bug():
    bug = get_bug()

    if not bug:
        return 0

    try:
        print 'sending ' + bug
        send_bug(bug)
        resource.os_unlink(bug)
        print 'sent ' + bug
        return 1
    except:
        print 'failed to send ' + bug
        return -1
Пример #8
0
    def unname(self,cookie):
        self.__scan()
        n = self.__c2n.get(cookie)

        if n is None:
            return action.nosync_return()

        n = '%s.name' % n.replace(' ','_')
        path = os.path.join(self.userdir,n)
        try: resource.os_unlink(path)
        except: pass

        self.__scan()
        self.__update()
        return action.nosync_return()
Пример #9
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:
        resource.os_unlink(dst)
    except:
        pass

    return False
Пример #10
0
def backup(file):
    dir = os.path.dirname(file)
    name = os.path.basename(file)

    spl = name.split()

    if len(spl) > 1:
        num = isint(spl[-1])
        if num is not None:
            name = ' '.join(spl[:-1])
        else:
            num = 1
    else:
        num = 1

    for x in xrange(num, 100000):
        nn = os.path.join(dir, '%s %d' % (name, x))
        if not resource.os_path_exists(nn):
            shutil.move(file, nn)
            return

    resource.os_unlink(file)