예제 #1
0
파일: repo.py 프로젝트: chyser/bin
def pull(db, args):
    #-------------------------------------------------------------------------------
    for a in oss.paths(args):

        nm = a.name_ext
        pth = db.get(nm)

        fpath = pth + '/' + nm
        print('pulling "%s" -> "%s' % (a, fpath))

        src = DIR + nm

        if not oss.exists(src):
            print("%s does not exist" % src)
            continue

        if oss.exists(fpath):
            ch = raw_input('overwrite "%s": (Y/n): ' % fpath)
            if ch == 'n':
                continue
            else:
                print('overwritten')

        db.rm(nm)
        oss.cp(src, fpath)
예제 #2
0
파일: dirsync.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    excludes, opts = oss.gopt(argv[1:], [('u', 'updest'), ('p', 'pretend')],
            [('s', 'src'), ('d', 'dest'), ('f', 'filters')], __doc__)

    if not opts.dest:
        opts.usage(1, "Must specify directories")

    src = opts.get('src', '.')
    print "src  =", src
    print "dest =", opts.dest
    print "excludes:", excludes

    if opts.filters is None:
        opts.filters = []
    else:
        if not isinstance(opts.filters, list):
            opts.filters = [opts.filters]
    print "filters:", opts.filters

    if not oss.exists(src):
        opts.usage(2, "Source directory '%s' does not exist" % src)

    if not oss.exists(opts.dest):
        opts.usage(2, "Destination directory '%s' does not exist" % opts.dest)

    if opts.updest:
        dsync.DirSync(src, opts.dest, excludes, opts.filters).UpdateDest(pretend=opts.pretend)
    else:
        dsync.DirSync(src, opts.dest, excludes, opts.filters).SyncDirs(pretend=opts.pretend)
예제 #3
0
파일: car_music.py 프로젝트: chyser/bin
def main(argv):
    #-------------------------------------------------------------------------------
    """ usage:
    """
    args, opts = oss.gopt(argv[1:], [('x', 'extra')], [],
                          main.__doc__ + __doc__)

    mp = set()

    oss.cd(MUSIC_PATH)
    for f in oss.find('.', '*.mp3'):
        dest = CAR_PATH + f[2:]
        d = dest.split('\\')[0] + '/'

        mp.add(f)

        if not oss.exists(d):
            oss.mkdir(d)

        if not oss.exists(dest) or oss.newerthan(f, dest):
            print(f, dest)
            cp(f, dest)

    if opts.extra:
        oss.cd(CAR_PATH)
        dp = set()

        for f in oss.find('.', '*.mp3'):
            dp.add(f)

        a = dp - mp
        for f in a:
            print(f)

    oss.exit(0)
예제 #4
0
파일: car_music.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    """ usage:
    """
    args, opts = oss.gopt(argv[1:], [('x', 'extra')], [], main.__doc__ + __doc__)

    mp = set()

    oss.cd(MUSIC_PATH)
    for f in oss.find('.', '*.mp3'):
        dest = CAR_PATH + f[2:]
        d = dest.split('\\')[0] + '/'

        mp.add(f)

        if not oss.exists(d):
            oss.mkdir(d)

        if not oss.exists(dest) or oss.newerthan(f, dest):
            print(f, dest)
            cp(f, dest)

    if opts.extra:
        oss.cd(CAR_PATH)
        dp = set()

        for f in oss.find('.', '*.mp3'):
            dp.add(f)

        a = dp - mp
        for f in a:
            print(f)

    oss.exit(0)
예제 #5
0
파일: repo.py 프로젝트: chyser/pylib
def pull(db, args):
#-------------------------------------------------------------------------------
    for a in oss.paths(args):

        nm = a.name_ext
        pth = db.get(nm)

        fpath = pth + '/' + nm
        print('pulling "%s" -> "%s' % (a, fpath))

        src = DIR + nm

        if not oss.exists(src):
            print("%s does not exist" % src)
            continue

        if oss.exists(fpath):
            ch = raw_input('overwrite "%s": (Y/n): ' % fpath)
            if ch == 'n':
                continue
            else:
                print('overwritten')

        db.rm(nm)
        oss.cp(src, fpath)
예제 #6
0
    def resolve(self, target, rule, lvl):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        """ resolve all dependencies, then build 'target' if needed.
        """
        ## all the dependencies that need to build will return events
        for e in [self.do(dep, lvl) for dep in rule.getDeps(target)]:
            if e is not None: e.wait()

        ## now that we have waited for any builds of dependencies, see if we should build
        if not oss.exists(target) or any((oss.exists(dep) and not oss.newerthan(target, dep) for dep in rule.getDeps(target))):
            return rule.execute(target, parallel=False)
예제 #7
0
파일: pmake.py 프로젝트: chyser/bin
def doFile(ddir, mfile, make, jobs, opts, args):
#-------------------------------------------------------------------------------
    if mfile is not None:
        makefile = mfile
        make = "nmake"

        if not oss.exists(makefile):
            print "%s doesn't exist" % makefile
            return 0

    else:
        if oss.exists('make.pmk'):
            makefile = 'make.pmk'
            makeCmd = 'make --win32' + jobs
        elif oss.exists('nmake.pmk'):
            makefile = 'nmake.pmk'
            makeCmd  = 'nmake'
        elif oss.exists('makefile'):
            makefile = 'makefile'
            makeCmd  = 'make --win32' + jobs
        else:
            return 0

    print '\nmaking:', ddir
    if make:
        makeCmd = make

    outfile = '/tmp/' + makefile + ".mak"

    tgtfile = makefile + ".mak"

    ret = 0
    try:
        GenMakefile(makefile, tgtfile, makeCmd)

        ret = 0
        cmd = ["%s -f %s" % (makeCmd, tgtfile)]

        if opts.define is not None:
            cmd.extend(['-D' + opts.define] if isinstance(opts.define, str) else ['-D %s' % d for d in opts.define])

        cmd.extend(args)
        cmd = ' '.join(cmd)

        print cmd
        print '-----------------------------------'
        ret = os.system(cmd)

    except Exception:
        traceback.print_exc()
        oss.rm(outfile)
        return 11

    return ret
예제 #8
0
파일: mvmusica.py 프로젝트: chyser/bin
def main(argv):
    #-------------------------------------------------------------------------------
    """ usage:
    """
    args, opts = oss.gopt(argv[1:], [('s', 'sync'), ('d', 'dup')], [],
                          main.__doc__ + __doc__)

    path = AMAZON_PATH
    tbl = string.maketrans('/\',', '-  ')

    for i in oss.find(path, '*.mp3'):
        ii = id3.ID3(i)
        try:
            title = chkName(ii['TITLE'])
            artist = chkName(ii['ARTIST'])
            print(artist, '---', title)

            if opts.sync:
                dir = BU_PATH + '/' + artist
                try:
                    if not oss.exists(dir):
                        oss.mkdir(dir)
                except IOError as ex:
                    print(i, "IOError: %s" % str(ex))
                    raise MyException('artist name error')
                except TypeError as ex:
                    print(i, "IOError: %s" % str(ex))
                    raise MyException('artist name error')

                fn = dir + '/' + title + '.mp3'
                if not oss.exists(fn):
                    print('%s --> %s' % (i, fn))
                    cp(i, fn)
                elif opts.dup and not oss.cmp(i, fn):
                    raise MyException('duplicate song')

        except KeyError as ex:
            print('%s -- KeyError: %s' % (i, str(ex)))
        except UnicodeDecodeError as ex:
            print('%s -- UnicodeDecodeError: %s' % (i, str(ex)))
        except IOError as ex:
            print('%s -- IOError: %s' % (i, str(ex)))
        except TypeError as ex:
            print('%s -- TypeError: %s' % (i, str(ex)))
        except MyException as ex:
            print('%s -- MyExceptionError: %s' % (i, str(ex)))

    oss.exit(0)
예제 #9
0
파일: config.py 프로젝트: chyser/bin
    def Load(self):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if not oss.exists(self.FileName):
            return []

        xm = xp.XMLParsePathList(self.FileName)
        cwins = []

        try:
            dct = xm.Parse(["/config/children/child", "/config/main_win_params", "/config/perspective"])

            res = dct["/config/main_win_params"][0][0]
            self.MainWindowSize = (int(res["width"]), int(res["height"]))
            self.MainWindowFlags = int(res["flags"])
            try:
                self.MainWindowPos =  (int(res["posx"]), int(res["posy"]))
            except KeyError:
                pass

            if "/config/children/child" in dct:
                for d, cdata in dct["/config/children/child"]:
                    cwins.append((d["name"], int(d["flags"])))

            if "/config/perspective" in dct:
                d = dct["/config/perspective"][0][0]
                self.Perspective = d['val']

        except:
            traceback.print_exc()
            print "Corrupted Config File -- Ignoring"

        return cwins
예제 #10
0
파일: readlog.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    """ usage: readlog.py <file> [<file> ...]

        continuously prints new lines added to files (like tail -f)
    """
    args, opts = oss.gopt(argv[1:], [], [], main.__doc__)

    fs = {};  last = None
    while 1:
        for f in args:
            if f not in fs and oss.exists(f):
                if last != f:
                    print('\n%s : -------------' % f)
                    last = f

                print("Opening:", f)
                last = f
                fs[f] = open(f, 'rU')
            else:
                if f in fs:
                    buf = fs[f].read(-1)
                    if buf:
                        if last != f:
                            print('\n%s : -------------' % f)
                            last = f
                        oss.stderr.write(buf)

            time.sleep(0.5)
예제 #11
0
파일: pylibs.py 프로젝트: chyser/bin
def checkPath(path):
#-------------------------------------------------------------------------------
    oss.cd(path)

    libs = []
    covered = set()
    for i in oss.paths(oss.ls('*.pth')):
        libs.append(i.name)
        for line in oss.readf(i):
            if line.strip().startswith('#'):
                continue
            covered.add(line)

    for i in oss.paths(oss.ls()):
        if i in covered:
            continue

        if i.ext == '.py':
            libs.append(i.name)

        if oss.IsDir(i):
            if oss.exists(i + '/__init__.py'):
                libs.append(i.name)

    return libs
예제 #12
0
파일: pylibs.py 프로젝트: chyser/bin
def checkPath(path):
    #-------------------------------------------------------------------------------
    oss.cd(path)

    libs = []
    covered = set()
    for i in oss.paths(oss.ls('*.pth')):
        libs.append(i.name)
        for line in oss.readf(i):
            if line.strip().startswith('#'):
                continue
            covered.add(line)

    for i in oss.paths(oss.ls()):
        if i in covered:
            continue

        if i.ext == '.py':
            libs.append(i.name)

        if oss.IsDir(i):
            if oss.exists(i + '/__init__.py'):
                libs.append(i.name)

    return libs
예제 #13
0
파일: copyit.py 프로젝트: chyser/bin
    def xferFile(self, srcFileName, destFileName):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if srcFileName in self.bad:
            return

        try:
            fs = oss.filesize(srcFileName)
        except WindowsError:
            return

        ## ensure file is completed
        if srcFileName not in self.rec:
            self.rec[srcFileName] = fs
            return

        if self.rec[srcFileName] == fs:
            try:
                oss.mv(srcFileName, destFileName)
                if not oss.exists(destFileName):
                    raise CopyException("bad copy")

                del self.rec[srcFileName]
                self.xfers.append('%s -> %s' % (srcFileName, destFileName))
                return fs
            except:
                oss.rm(destFileName)
                self.bad.add(srcFileName)
        else:
            print("  @@", srcFileName, self.rec[srcFileName], fs)
            self.rec[srcFileName] = fs

        return
예제 #14
0
파일: config.py 프로젝트: chyser/bin
    def Load(self):
        #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if not oss.exists(self.FileName):
            return []

        xm = xp.XMLParsePathList(self.FileName)
        cwins = []

        try:
            dct = xm.Parse([
                "/config/children/child", "/config/main_win_params",
                "/config/perspective"
            ])

            res = dct["/config/main_win_params"][0][0]
            self.MainWindowSize = (int(res["width"]), int(res["height"]))
            self.MainWindowFlags = int(res["flags"])
            try:
                self.MainWindowPos = (int(res["posx"]), int(res["posy"]))
            except KeyError:
                pass

            if "/config/children/child" in dct:
                for d, cdata in dct["/config/children/child"]:
                    cwins.append((d["name"], int(d["flags"])))

            if "/config/perspective" in dct:
                d = dct["/config/perspective"][0][0]
                self.Perspective = d['val']

        except:
            traceback.print_exc()
            print "Corrupted Config File -- Ignoring"

        return cwins
예제 #15
0
def main(argv):
    #-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [], usage)

    cvsdwn = not CvsRootCheck()

    for f in oss.paths(args):
        ext = oss.splitext(f).lower()
        opts = '-kb' if ext in BinExts else ''

        if cvsdwn:
            otf = file('CVS/offline', 'a')
            print >> otf, 'add ' + opts + ' ' + f
            otf.close()
        else:
            if oss.exists('CVS/offline'):
                inf = file('CVS/offline')
                for cmd in inf:
                    oss.r('cvs.exe ' + cmd)
                inf.close()
                oss.rm('CVS/offline')

            oss.r('cvs.exe add ' + opts + ' ' + f)

    oss.exit(0)
예제 #16
0
def main(argv):
    #-------------------------------------------------------------------------------
    """ usage: readlog.py <file> [<file> ...]

        continuously prints new lines added to files (like tail -f)
    """
    args, opts = oss.gopt(argv[1:], [], [], main.__doc__)

    fs = {}
    last = None
    while 1:
        for f in args:
            if f not in fs and oss.exists(f):
                if last != f:
                    print('\n%s : -------------' % f)
                    last = f

                print("Opening:", f)
                last = f
                fs[f] = open(f, 'rU')
            else:
                if f in fs:
                    buf = fs[f].read(-1)
                    if buf:
                        if last != f:
                            print('\n%s : -------------' % f)
                            last = f
                        oss.stderr.write(buf)

            time.sleep(0.5)
예제 #17
0
파일: cvs_add.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [], usage)

    cvsdwn = not CvsRootCheck()

    for f in oss.paths(args):
        ext = oss.splitext(f).lower()
        opts = '-kb' if ext in BinExts else ''

        if cvsdwn:
            otf = file('CVS/offline', 'a')
            print >> otf, 'add ' + opts + ' ' + f
            otf.close()
        else:
            if oss.exists('CVS/offline'):
                inf = file('CVS/offline')
                for cmd in inf:
                    oss.r('cvs.exe ' + cmd)
                inf.close()
                oss.rm('CVS/offline')

            oss.r('cvs.exe add ' + opts + ' ' + f)

    oss.exit(0)
예제 #18
0
파일: cf.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    """ usage: cf.py [options]

        options:
            -n | --nocheck    : don't check for CVSROOT

        show files in CVS/MTN that are changed in local directory
    """
    args, opt = oss.gopt(oss.argv[1:], [('n', 'nocheck')], [], main.__doc__)

    if oss.exists('CVS'):
        if opt.nocheck is None: CvsRootCheck()

        if not args:
            oss.r(r'C:\bin\cvs.exe -qn up -A | C:\mksnt\fgrep.exe -v "?"')
        else:
            for dir in args:
                oss.cd(dir)
                oss.r(r'C:\bin\cvs.exe -qn up -A | C:\mksnt\fgrep.exe -v "?"')

    elif oss.findFilePathUp('_MTN'):
        oss.r('mtn status')
        #print '\nunknown files:'
        #oss.r('mtn ls unknown')

    oss.exit(0)
예제 #19
0
def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [('r', 'recurse'), ('q', 'quick'), ('s', 'supress')],
                          [('d', 'dir')], [], [('x', 'exts')], __doc__)

    if not args:
        opts.usage(1, 'Must specify directories')

    if len(args) == 1:
        args.append('.')

    if opts.dir:
        args = ['{0}/{1}'.format(a, opts.dir) for a in args]

    for a in args:
        if not oss.exists(a):
            opts.usage(2, '"{0}" does not exist'.format(a))

    exts = set(['.{0}'.format(e) for e in opts.exts]) if opts.exts else None

    p = []
    for a0, a1 in util.permutations(len(args)):
        same = checkDir(args[a0], args[a1], exts, opts.quick, opts.recurse, opts.supress)
        p.append('    {0} {1} {2}'.format(args[a0], '==' if same else '!=', args[a1]))

    print('Status:')
    for i in p:
        print(i)
    oss.exit(0)
예제 #20
0
파일: mvmusica.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    """ usage:
    """
    args, opts = oss.gopt(argv[1:], [('s', 'sync'), ('d', 'dup')], [], main.__doc__ + __doc__)

    path = AMAZON_PATH
    tbl = string.maketrans('/\',', '-  ')

    for i in oss.find(path, '*.mp3'):
        ii = id3.ID3(i)
        try:
            title = chkName(ii['TITLE'])
            artist = chkName(ii['ARTIST'])
            print(artist, '---', title)

            if opts.sync:
                dir = BU_PATH + '/' + artist
                try:
                    if not oss.exists(dir):
                        oss.mkdir(dir)
                except IOError as ex:
                    print(i, "IOError: %s" % str(ex))
                    raise MyException('artist name error')
                except TypeError as ex:
                    print(i, "IOError: %s" % str(ex))
                    raise MyException('artist name error')

                fn = dir + '/' + title + '.mp3'
                if not oss.exists(fn):
                    print('%s --> %s' % (i, fn))
                    cp(i, fn)
                elif opts.dup and not oss.cmp(i, fn):
                    raise MyException('duplicate song')

        except KeyError as ex:
            print('%s -- KeyError: %s' % (i, str(ex)))
        except UnicodeDecodeError as ex:
            print('%s -- UnicodeDecodeError: %s' % (i, str(ex)))
        except IOError as ex:
            print('%s -- IOError: %s' % (i, str(ex)))
        except TypeError as ex:
            print('%s -- TypeError: %s' % (i, str(ex)))
        except MyException as ex:
            print('%s -- MyExceptionError: %s' % (i, str(ex)))

    oss.exit(0)
예제 #21
0
파일: mkbatpy.py 프로젝트: chyser/bin
def create(fn, force = False, python="python.exe"):
#-------------------------------------------------------------------------------
    if not oss.exists(fn):
        return

    oname = oss.replaceExt(fn, '.bat')

    if not force and oss.exists(oname):
        print(oname, "already exists")
        return True

    with open(oname, 'w') as otf:
        print("""echo off\n%s C:\\bin\\%s %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9""" % (python, fn), file=otf)

    oss.r("cvs add %s" % oname)
    oss.r('cvs ci -m "new file" %s' % oname)
    return True
예제 #22
0
파일: runit.py 프로젝트: chyser/bin
def look_out(a):
#-------------------------------------------------------------------------------
    while 1:
        time.sleep(1)
        if oss.exists("/tmp/runit_die"):
            print("killing main")
            thread.interrupt_main()
            raise BaseException()
예제 #23
0
파일: mkcvs.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    """ usage: mkcvs [OPTIONS] <dir>
        Makes a cvs archive from the specified directory

        Options:
            -i | --ignore    :  specify extensions or files or directories to ignore
                                example: -i .bmp -i .jpg  or  -i badfile

"""
    args, opts = oss.gopt(argv[1:], [], [], [], [('i', 'ignore')], main.__doc__)

    if not oss.exists(oss.env['CVSROOT']):
        print "CVSROOT is down"
        oss.exit(1)

    if args:
       oss.cd(args[0])

    name = oss.basename(oss.pwd())

    if oss.exists(oss.env['CVSROOT'] + '/' + name):
        print >> oss.stderr, "Already exists:", oss.env['CVSROOT'] + '/' + name
        oss.exit(1)

    if opts.ignore is not None:
        if isinstance(opts.ignore, list):
            IGNORE_PATTERNS.extend(opts.ignore)
        else:
            IGNORE_PATTERNS.append(opts.ignore)

    il = bldIgnoreList()
    print "Ignoring Files: '%s'" % il

    oss.r(r'C:\bin\cvs.exe import %s %s %s %s1' % (il, name, name, name))
    oss.cd('..')
    oss.r("mv %s /tmp/%s.bak" % (name, name))

    oss.r(r'C:\bin\cvs.exe co %s' % name)

    oss.cd(name)
    for f in oss.ls():
        print f

    oss.r("C:\bin\cf.py")
    oss.exit(0)
예제 #24
0
파일: runit.py 프로젝트: chyser/bin
def look_out(a):
    #-------------------------------------------------------------------------------
    while 1:
        time.sleep(1)
        if oss.exists("/tmp/runit_die"):
            print("killing main")
            thread.interrupt_main()
            raise BaseException()
예제 #25
0
파일: mycvs.py 프로젝트: chyser/bin
    def checkfor(self, dir = '.'):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        lst = []

        if not oss.exists('CVS/Entries'):
            return

        ## get list of files
        inf = file('CVS/Entries')
        have = set()
        for line in inf:
            try:
                have.add(line.split('/')[1])
            except:
                pass

        inf.close()

        try:
            igf = file(".cffignore")
            for line in igf:
                line = line[:-1]
                have.add(line)
        except IOError:
            pass

        inf.close()

        for f in oss.ls():
            f = oss.basename(f)
            if self.ignoreFile(f):
                continue

            if oss.IsDir(f):
                if not oss.exists(f + '/CVS'):
                    if f not in have:
                        lst.append("%s/%s/" % (dir, f))
                else:
                    oss.pushcd(f)
                    lst.extend(self.checkfor(dir + '/' + f))
                    oss.popcd()
            elif f not in have:
                lst.append("%s/%s" % (dir, f))

        return lst
예제 #26
0
def backup():
    #-------------------------------------------------------------------------------
    for f in oss.find(MUSIC_PATH, '*.mp3'):
        print(f)

        ff = BU_PATH + '\\' + oss.basename(f)
        if not oss.exists(ff):
            print('   ', "copied")
            cp(f, ff)
예제 #27
0
파일: mycvs.py 프로젝트: chyser/bin
    def CvsRootCheck(self):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if self.root is None:
            self.root = oss.readf('CVS/Root', 0)

        if self.root is None:
            self.root = oss.env['CVSROOT']

        return self.root.startswith(':pserver:') or oss.exists(self.root)
예제 #28
0
파일: mycvs.py 프로젝트: chyser/bin
    def sync(self, args=None, opts=None):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if not oss.exists('./CVS/Entries'):
            print('must be in root cvs directory')
            return

        with open('./CVS/Entries', 'rU') as inf:
            files = set()

            for line in inf:
                d = line.split('/')
                files.add(d[1])

        rset = [f for f in files if not oss.exists(f)]

        print(rset)
        if self.validate():
            self.rm(rset)
예제 #29
0
파일: config.py 프로젝트: chyser/bin
    def Open(self, FileName):
        #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        self._filename = oss.expanduser(FileName)
        print "ConfigObject:", self._filename
        if not oss.exists(self._filename):
            self.Save()

        self._wt = oss.FileTimeInt(self._filename)
        self.Load()
예제 #30
0
파일: config.py 프로젝트: chyser/bin
    def Open(self, FileName):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        self._filename = oss.expanduser(FileName)
        print "ConfigObject:", self._filename
        if not oss.exists(self._filename):
            self.Save()

        self._wt = oss.FileTimeInt(self._filename)
        self.Load()
예제 #31
0
def backup():
#-------------------------------------------------------------------------------
    for f in oss.find(MUSIC_PATH, '*.mp3'):
        print(f)

        ff = BU_PATH + '\\' + oss.basename(f)
        if not oss.exists(ff):
            print('   ', "copied")
            cp(f, ff)
예제 #32
0
def CvsRootCheck():
    #-------------------------------------------------------------------------------
    root = oss.readf('CVS/Root', 0)

    if root is None:
        root = oss.env['CVSROOT']

    if root[:9] != ':pserver:' and not oss.exists(root):
        return False

    return True
예제 #33
0
def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [], usage)

    for fn in args:
        if not oss.exists(fn):
            usage(1, "%s does not exist" % fn)

        oss.r('python C:/bin/zippy.py -z -c tt.zip %s/*' % fn)
        oss.r('crypt <tt.zip > %s.sec' % (fn))
        oss.rm('tt.zip')
예제 #34
0
파일: config.py 프로젝트: chyser/bin
    def __init__(self, obj, filename, defaultDir = "~/cfgs/"):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        BaseConfigObject.__init__(self, obj)

        self._defaultDir = defaultDir + ('/' if defaultDir else '')
        self._wt = None

        if defaultDir and not oss.exists(defaultDir):
            oss.mkdir(defaultDir)

        self.Open(self._defaultDir + filename)
예제 #35
0
파일: mkbatpy.py 프로젝트: chyser/bin
def create(fn, force=False, python="python.exe"):
    #-------------------------------------------------------------------------------
    if not oss.exists(fn):
        return

    oname = oss.replaceExt(fn, '.bat')

    if not force and oss.exists(oname):
        print(oname, "already exists")
        return True

    with open(oname, 'w') as otf:
        print(
            """echo off\n%s C:\\bin\\%s %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9"""
            % (python, fn),
            file=otf)

    oss.r("cvs add %s" % oname)
    oss.r('cvs ci -m "new file" %s' % oname)
    return True
예제 #36
0
파일: mycvs.py 프로젝트: chyser/bin
 def updateOffline(self):
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     """ if some offline operations were queued, execute them if online
     """
     if self.cvsup and oss.exists('CVS/offline'):
         inf = file('CVS/offline')
         for cmd in inf:
             oss.r(self.exe + cmd)
         inf.close()
         oss.rm('CVS/offline')
         return True
예제 #37
0
파일: cvs_add.py 프로젝트: chyser/bin
def CvsRootCheck():
#-------------------------------------------------------------------------------
    root = oss.readf('CVS/Root', 0)

    if root is None:
        root = oss.env['CVSROOT']

    if root[:9] != ':pserver:' and not oss.exists(root):
        return False

    return True
예제 #38
0
파일: config.py 프로젝트: chyser/bin
    def __init__(self, obj, filename, defaultDir="~/cfgs/"):
        #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        BaseConfigObject.__init__(self, obj)

        self._defaultDir = defaultDir + ('/' if defaultDir else '')
        self._wt = None

        if defaultDir and not oss.exists(defaultDir):
            oss.mkdir(defaultDir)

        self.Open(self._defaultDir + filename)
예제 #39
0
    def __init__(self, fileName, key):
        #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        object.__init__(self)
        self.fileName = fileName
        self.revision = "1.0"

        self.entries = []
        self.names = {}
        self.es = es.EncryptedStorageObj(self.fileName, key)

        if oss.exists(self.fileName):
            self.load()
예제 #40
0
파일: cff.py 프로젝트: chyser/bin
def main(argv):
    #-------------------------------------------------------------------------------
    """
    usage: cff
        -i | --ignore      : ignore this file (or filespec)
        -l | --ignorelist  : dump list of ignored files
        -a | --add         : add the files to CVS

    list the files that have NOT been checked into the CVS archive

    """
    args, opts = oss.gopt(argv[1:], [('l', 'ignorelist'), ('a', 'add')], [],
                          [], [('i', 'ignore')], main.__doc__)

    if oss.exists('CVS'):
        if opts.ignore:
            with open(".cffignore", "a") as igf:
                for i in opts.ignore:
                    print(i, file=igf)
                oss.exit(0)

        if opts.add is not None:
            lst = doDir()
            for l in lst:
                print('cvs add ' + oss.basename(l))
                oss.r('cvs add ' + oss.basename(l))
            oss.exit(0)

        if opts.ignorelist is not None:
            lst = list(mkcvs.IGNORE_PATTERNS)
            with open(".cffignore") as igf:
                for line in igf:
                    line = line[:-1]
                    lst.append(line)
            print(lst)

        lst = doDir()
        for l in lst:
            print(l)

    else:
        print('montone')
        pth = oss.findFilePathUp('_MTN')

        if pth:
            lst = oss.r('mtn ls unknown', '|').split('\n')
            pwd = oss.normpath(oss.pwd())

            for i in lst:
                if (pth + i).startswith(pwd):
                    print(i)

    oss.exit(0)
예제 #41
0
파일: cf.py 프로젝트: chyser/bin
def CvsRootCheck():
#-------------------------------------------------------------------------------
    root = oss.readf('CVS/Root', 0)

    if root is None:
        root = oss.env['CVSROOT']

    if root[:9] != ':pserver:' and not oss.exists(root):
        print("CVSROOT('%s') is down" % root)
        oss.exit(1)

    print("CVS Root: '%s'" % root)
예제 #42
0
 def getFileName(self, msg, exists):
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     while 1:
         fn = raw_input(msg + ' ')
                     
         if fn == 'CANCEL':
             return None
             
         if exists:
             if oss.exists(fn):
                 return fn
             print("no such file")
             
         else:
             if oss.exists(fn):
                 print("file exists")
                 c = raw_input("overwrite? (y/n)")
                 if c in "Yy":
                     return fn
             else:
                 return fn
예제 #43
0
    def __init__(self, fileName, key):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        object.__init__(self)
        self.fileName = fileName
        self.revision = "1.0"

        self.entries = []
        self.names = {}
        self.es = es.EncryptedStorageObj(self.fileName, key)

        if oss.exists(self.fileName):
            self.load()
예제 #44
0
파일: cff.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    """
    usage: cff
        -i | --ignore      : ignore this file (or filespec)
        -l | --ignorelist  : dump list of ignored files
        -a | --add         : add the files to CVS

    list the files that have NOT been checked into the CVS archive

    """
    args, opts = oss.gopt(argv[1:], [('l', 'ignorelist'), ('a', 'add')], [], [], [('i', 'ignore')], main.__doc__)

    if oss.exists('CVS'):
        if opts.ignore:
            with open(".cffignore", "a") as igf:
                for i in opts.ignore:
                    print(i, file=igf)
                oss.exit(0)

        if opts.add is not None:
            lst = doDir()
            for l in lst:
                print('cvs add ' + oss.basename(l))
                oss.r('cvs add ' + oss.basename(l))
            oss.exit(0)

        if opts.ignorelist is not None:
            lst = list(mkcvs.IGNORE_PATTERNS)
            with open(".cffignore") as igf:
                for line in igf:
                    line = line[:-1]
                    lst.append(line)
            print(lst)

        lst = doDir()
        for l in lst:
            print(l)

    else:
        print('montone')
        pth = oss.findFilePathUp('_MTN')

        if pth:
            lst = oss.r('mtn ls unknown', '|').split('\n')
            pwd = oss.normpath(oss.pwd())

            for i in lst:
                if (pth + i).startswith(pwd):
                    print(i)

    oss.exit(0)
예제 #45
0
    def do(self, target, lvl=0):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        """ find a rule for 'target', resolve dependencies and build if necessary
        """
        rule = self.rules.findMatch(target)

        ## if there is no way to build 'target' then don't wait on the build
        if rule is None:
            if not oss.exists(target):
                Error('File does not exist. "%s"' % target)
            return

        ## resolve dependencies and then build 'target' if needed
        return self.resolve(target, rule, lvl+1)
예제 #46
0
파일: repo.py 프로젝트: chyser/bin
def push(db, args):
    #-------------------------------------------------------------------------------
    for a in oss.paths(args):
        print('pushing "%s"' % a)

        pth = a.fpath
        nm = a.name_ext

        if not oss.exists(a):
            print('"%s" does not exist' % a)
            continue

        dest = DIR + nm
        if oss.exists(dest):
            print("warning: saved %s exists" % nm)
            ch = raw_input("overwrite: (Y/n): ")
            if ch == 'n':
                continue
            else:
                print('overwritten')

        print(nm, pth)
        db.put(nm, pth)
        oss.cp(a, DIR)
예제 #47
0
파일: autoflv.py 프로젝트: chyser/bin
def getFile(name, url, num_connections='4', speed='300000'):
#-------------------------------------------------------------------------------
        nn = name + '.dwn'

        if oss.exists(name) or oss.exists(nn):
            print('File Exists:', name)
            return

        cl = '%s -n %s -s %s -o %s  %s' % (DOWNLOADER, num_connections, speed, nn, url)
        print(time.ctime())
        print('cmd: "%s"' % cl)
        st = util.TimeElapsed()

        p = subprocess.Popen(cl, shell=False, stdout=subprocess.PIPE)
        so = p.stdout

        for line in so:
            try:
                wd = line.split()[0]
                if wd in set(['Initializing', 'File', 'Downloaded', 'Starting', 'Connection']):
                    print(line[:-1])

                if st.check(60):
                    print(line[:-1])

            except IndexError:
                pass

        p.wait()

        if p.returncode == 0:
            oss.mv(nn, name)
            print()
            return True

        print('Error:', p.returncode)
예제 #48
0
def GetObjectObjs(fname):
#-------------------------------------------------------------------------------
    """ (hlist, clist) = GetObjectObjs(fname)
          hlist: list of header dependecies
          clist: list of obj dependecies
    """

    hlist = CPPMkDepsList(fname)
    clist = [fname]

    for i in hlist:
        nm = oss.splitnm(i) + '.cpp'
        if oss.exists(nm):
            clist.append(nm)
    return hlist, clist
예제 #49
0
파일: beautify.py 프로젝트: chyser/bin
def DoPython(InputFileName, Force=None):
#-------------------------------------------------------------------------------
    if gDEBUG:
        PythonTokenizer(InputFileName)
        return

    BUFileName = oss.basename(InputFileName) + ".beautify"
    OutputFileName = InputFileName

    if not Force and oss.exists(BUFileName):
        print >> sys.stderr, "Cannot make backup file '%s'" % BUFileName
        sys.exit(3)

    oss.mv(InputFileName, BUFileName)
    PythonTokenizer(BUFileName, OutputFileName)
예제 #50
0
def main(argv):
#-------------------------------------------------------------------------------
    """ usage: myedit.py <files> [<files> ...]

        frontend to myedit
    """
    args, opts = oss.gopt(argv[1:], [], [], main.__doc__ + __doc__)
    ff = [oss.canonicalPath(arg) for arg in args]

    for f in ff:
        if not oss.exists(f):
            oss.touch(f)

    oss.r('C:/python26/python.exe C:/home/chrish/work/myedit/myedit.py -X -s ' + ' '.join(ff))
    oss.exit(0)
예제 #51
0
파일: repo.py 프로젝트: chyser/pylib
def push(db, args):
#-------------------------------------------------------------------------------
    for a in oss.paths(args):
        print('pushing "%s"' % a)

        pth = a.fpath
        nm = a.name_ext

        if not oss.exists(a):
            print('"%s" does not exist' % a)
            continue

        dest = DIR + nm
        if oss.exists(dest):
            print("warning: saved %s exists" % nm)
            ch = raw_input("overwrite: (Y/n): ")
            if ch == 'n':
                continue
            else:
                print('overwritten')

        print(nm, pth)
        db.put(nm, pth)
        oss.cp(a, DIR)
예제 #52
0
파일: beautify.py 프로젝트: chyser/bin
def DoPython(InputFileName, Force=None):
    #-------------------------------------------------------------------------------
    if gDEBUG:
        PythonTokenizer(InputFileName)
        return

    BUFileName = oss.basename(InputFileName) + ".beautify"
    OutputFileName = InputFileName

    if not Force and oss.exists(BUFileName):
        print >> sys.stderr, "Cannot make backup file '%s'" % BUFileName
        sys.exit(3)

    oss.mv(InputFileName, BUFileName)
    PythonTokenizer(BUFileName, OutputFileName)