예제 #1
0
파일: mycvs.py 프로젝트: chyser/bin
    def update(self, args, opts):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        """ updates file or directories

        @type  args: sequence
        @param args: sequence of files or directories to update
        @rtype: string
        @return: returns output of the cvs commands
        """

        if not self.cvsup:
            print('CVS Archive "%s" is down' % self.root, file=oss.stderr)
            return ""

        if not args:
            return oss.r(self.exe + ' up -d', '|')

        res = []
        for f in args:
            if oss.IsDir(f):
                oss.pushcd(f)
                res.append(oss.r(self.exe + ' up -d', '|'))
                oss.popcd()
            else:
                res.append(oss.r(self.exe + ' up ' + f, '|'))
        return '\n'.join(res)
예제 #2
0
파일: mycvs.py 프로젝트: chyser/bin
    def check(self, args=None, opts=None):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        """ checks files or directories

        @type  args: sequence
        @param args: sequence of files or directories to check
        """
        if not self.cvsup:
            print('CVS Archive "%s" is down' % self.root, file=oss.stderr)
            return ''

        res = []
        if not args:
            for s in oss.r(self.exe + '-qn up -A ', '|').split('\n'):
                if not s.startswith('?'):
                    res.append(s)
            return '\n'.join(res)

        for f in args:
            if oss.IsDir(f):
                if oss.pushcd(f):
                    for s in oss.r(self.exe + '-qn up -A ', '|').split('\n'):
                        if not s.startswith('?'):
                            res.append(s)
                    oss.popcd()
            else:
                res.append(oss.r(self.exe + '-qn up -A ' + f, '|'))
        return '\n'.join(res)
예제 #3
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)
예제 #4
0
파일: mycvs.py 프로젝트: chyser/bin
    def ci(self, args, opts):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        """ checks the files in. if directories are specified, goes there first

        @type  msg: string
        @param msg: check in message
        @type  args: sequence
        @param args: sequence of files or directories to check in
        @rtype: string
        @return: returns output of the cvs commands
        """

        if not self.cvsup:
            print('CVS Archive "%s" is down' % self.root, file=oss.stderr)
            return ""

        msg = opts.get('msg', '--')
        if not msg: msg = '--'

        if not args:
            #print(self.exe + ' ci -m "%s"' % msg)
            return oss.r(self.exe + ' ci -m "%s"' % msg, '|')
            #return oss.r(self.exe + ' ci -m "%s"' % msg)

        res = []
        for f in args:
            if oss.IsDir(f):
                oss.pushcd(f)
                res.append(oss.r(self.exe + ' ci -m "%s"' % msg, '|'))
                oss.popcd()
            else:
                res.append(oss.r(self.exe + ' ci -m "%s" %s' % (msg, f), '|'))
        return '\n'.join(res)
예제 #5
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)
예제 #6
0
파일: cvt_flv_mp3.py 프로젝트: chyser/bin
def main(argv):
    #-------------------------------------------------------------------------------
    """ usage:
    """
    print(argv)
    args, opts = oss.gopt(argv[1:], [], [], main.__doc__ + __doc__)
    la = len(args)
    print(la)

    print(args)
    if not (0 < la < 3):
        oss.usage(
            1,
            "usage: cvt_flv_mp3.py <file_name.flv> [<output_file_name.mp3>]")
    elif la == 2:
        pth, fn, ext = oss.splitFilename(args[0])
        if not pth: pth = '.'
        infn = fn + '.flv'
        print(infn)
        pth, fn, ext = oss.splitFilename(args[1])
        if not pth: pth = '.'
        outfn = pth + '\\' + fn + '.mp3'
    else:
        pth, fn, ext = oss.splitFilename(args[0])
        if not pth: pth = '.'
        infn = fn + '.flv'
        outfn = pth + '\\' + fn + '.mp3'

    print("Pulling '%s' from '%s'" % (outfn, infn))
    oss.r(FFMPEG % (infn, outfn))
    oss.exit(0)
예제 #7
0
파일: vnc.py 프로젝트: chyser/bin
def main(argv):
    #-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [('r', 'rmtport'), ('l', 'locport')],
                          usage)

    if opts.locport:
        locport = int(opts.locport)
    else:
        locport = random.randint(5905, 5930)

    display = locport - 5900
    rmtport = 5901

    if len(args) != 1:
        usage(1)

    if ':' in args[0]:
        mach, rp = args[0].split(':')
        rmtport = int(rp) + 5900
    else:
        mach = args[0]

    if opts.rmtport:
        rmtport = int(opts.rmtport)

    t = threading.Thread(target=makeTunnel, args=(locport, mach, rmtport))
    t.setDaemon(True)
    t.start()

    time.sleep(5)
    oss.cd("C:/Program Files/tightvnc/")
    oss.r('vncviewer.exe %s:%d' % ('localhost', display))

    oss.exit(0)
예제 #8
0
파일: cvt_flv_mp3.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    """ usage:
    """
    print(argv)
    args, opts = oss.gopt(argv[1:], [], [], main.__doc__ + __doc__)
    la = len(args)
    print(la)

    print(args)
    if not (0 < la < 3):
        oss.usage(1, "usage: cvt_flv_mp3.py <file_name.flv> [<output_file_name.mp3>]")
    elif la == 2:
        pth, fn, ext = oss.splitFilename(args[0])
        if not pth: pth = '.'
        infn = fn + '.flv'
        print(infn)
        pth, fn, ext = oss.splitFilename(args[1])
        if not pth: pth = '.'
        outfn = pth + '\\' + fn + '.mp3'
    else:
        pth, fn, ext = oss.splitFilename(args[0])
        if not pth: pth = '.'
        infn = fn + '.flv'
        outfn = pth + '\\' + fn + '.mp3'

    print("Pulling '%s' from '%s'" % (outfn, infn))
    oss.r(FFMPEG % (infn, outfn))
    oss.exit(0)
예제 #9
0
def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [], usage)

    for fn in args:
        print fn
        oss.r('crypt <%s >tt.zip' % (fn))
        oss.r('python C:/bin/zippy.py tt.zip')
    oss.rm('tt.zip')
예제 #10
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
예제 #11
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')
예제 #12
0
파일: cvs_up.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [], usage)

    if not args:
        args = ['.']

    for dir in args:
        oss.cd(dir)
        oss.r('cvs.exe up -d')

    oss.exit(0)
예제 #13
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)
예제 #14
0
def main(argv):
    #-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [], usage)

    if not args:
        args = ['.']

    for dir in args:
        oss.cd(dir)
        oss.r('cvs.exe up -d')

    oss.exit(0)
예제 #15
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)
예제 #16
0
def main(argv):
    #-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [('m', 'msg'), ('d', 'db')], usage)

    options = "--db " + opts.db if opts.db else ''

    if args and args[0] == 'ci':
        f = oss.r('mtn.exe %s ci -m "%s"' % (options, args[2]), '<')
        f.write('kibsop)')
        f.close()
    else:
        oss.r("mtn.exe " + options + ' ' + ' '.join(args))

    oss.exit(0)
예제 #17
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)
예제 #18
0
파일: mmtn.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [('m', 'msg'), ('d', 'db')], usage)

    options = "--db " + opts.db if opts.db else ''

    if args and args[0] == 'ci':
        f = oss.r('mtn.exe %s ci -m "%s"' % (options, args[2]), '<')
        f.write('kibsop)')
        f.close()
    else:
        oss.r("mtn.exe " + options + ' ' + ' '.join(args))


    oss.exit(0)
예제 #19
0
파일: cvs_ci.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [('m', 'msg')], usage)

    if opts.msg is None:
        opts.msg = ""

    if not args:
        args = ['.']

    for dir in args:
        oss.cd(dir)
        oss.r('cvs.exe ci -m "%s"' % opts.msg)

    oss.exit(0)
예제 #20
0
def main(argv):
    #-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [('m', 'msg')], usage)

    if opts.msg is None:
        opts.msg = ""

    if not args:
        args = ['.']

    for dir in args:
        oss.cd(dir)
        oss.r('cvs.exe ci -m "%s"' % opts.msg)

    oss.exit(0)
예제 #21
0
파일: wnet.py 프로젝트: chyser/bin
def getWNetworks(nic):
    #-------------------------------------------------------------------------------
    n = []
    s = oss.r("%s %s scan" % (IWLIST, nic), '|')

    state = 0
    net = None
    for line in s.split('\n'):
        line = line.strip()

        if state == 0:
            if line.find('Cell') == 0:
                net = WNet()
                state = 1

        elif state == 1:
            if line.find('Encryption') == 0:
                net.encrypt = line.split(':')[1]

            elif line.find('Quality') == 0:
                t = line.split()[0]
                net.qual = t.split('=')[1]

            elif line.find('ESSID') == 0:
                name = line.split(':')[1][1:-1]
                if name:
                    net.name = name
                    n.append(net)

            elif line.find('Mode') == 0:
                state = 0

    return n
예제 #22
0
파일: wnet.py 프로젝트: chyser/bin
def getWNetworks(nic):
#-------------------------------------------------------------------------------
    n = []
    s = oss.r("%s %s scan" % (IWLIST, nic), '|')

    state = 0
    net = None
    for line in s.split('\n'):
	line = line.strip()

        if state == 0:
            if line.find('Cell') == 0:
	        net = WNet()
	        state = 1

        elif state == 1:
            if line.find('Encryption') == 0:
	        net.encrypt = line.split(':')[1]

            elif line.find('Quality') == 0:
	        t = line.split()[0]
		net.qual = t.split('=')[1]

            elif line.find('ESSID') == 0:
	        name = line.split(':')[1][1:-1]
	        if name:
		    net.name = name
	            n.append(net)

            elif line.find('Mode') == 0:
	        state = 0

    return n
예제 #23
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
예제 #24
0
파일: mycvs.py 프로젝트: chyser/bin
    def decvs(self, args, opts):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        for f in oss.ls():
            bf = oss.basename(f)

            if bf.lower() == 'cvs':
                print('removing:', f)
                oss.r('rm -rf cvs')
                continue

            if self.ignoreFile(bf):
                continue

            if oss.IsDir(bf):
                oss.pushcd(bf)
                self.decvs(args, opts)
                oss.popcd()
예제 #25
0
파일: uncvs.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    """
    usage: uncvs [<dir>]

    Remove CVS from a directory if specified, else the current directory
    """
    args, opts = oss.gopt(argv[1:], [], [], main.__doc__)

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

    for dd in oss.find('.', 'CVS'):
        if oss.exists(dd + '/ROOT'):
            print("Removing:", dd)
            oss.r("rm -rf " + dd)

    oss.exit(0)
예제 #26
0
파일: mycvs.py 프로젝트: chyser/bin
    def _issueCmd(self, cmd):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        """ used for functions that can effectively work offline

            @type  cmd: string
            @param cmd: the command and command line to be passed to cvs
        """

        if self.cvsup:
            print(self.exe + cmd)
            oss.r(self.exe + cmd)
        else:
            try:
                otf = file('CVS/offline', 'a')
                otf.write(cmd + '\n')
                otf.close()
            except IOError:
                print("No project for offline", file=oss.stderr)
예제 #27
0
def makeTunnel(loc, mach, rmt):
    #-------------------------------------------------------------------------------
    idx = 1

    while 1:
        st = time.time()

        print 'Connecting local port %d to %s:%d' % (loc, mach, rmt)
        oss.r(
            'plink -l chrish -pw kibsop) -N -L %d:%s:%d compflu-02.hpl.hp.com '
            % (loc, mach, rmt))

        if st + 60 < time.time():
            time.sleep(10 * idx)
            idx += 1
            if idx > 6:
                idx = 1
        else:
            idx = 1
예제 #28
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
예제 #29
0
def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [('d', 'delete')], [], usage)

    la = len(args)

    if la < 1:
        usage('insufficient arguments')

    tgt = args[0]

    if la == 1:
        if opts.delete:
            rc = oss.r('linkd.exe "%s" /D' % tgt)
        else:
            rc = oss.r('linkd.exe "%s" "%s"' % (oss.basename(tgt), tgt))
    else:
        rc = oss.r('linkd.exe "%s" "%s"' % (args[1], tgt))

    oss.exit(rc)
예제 #30
0
파일: beautify.py 프로젝트: chyser/bin
    def run(self, fn, force=False):
        #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        oss.r('indent1.exe ' + self.indentOptions + ' ' + fn)
        return
        bfn = self.makeBU(fn, force)

        inf = open(bfn, 'rU')
        otf = open(fn, 'w')

        ol2 = ol1 = ls = None

        for line in inf:
            ol2 = ol1
            ol1 = ls
            ls = line.strip()

            if not ls:
                otf.write('\n')
                continue

            if ls.startswith('if') or ls.startswith('for') or ls.startswith(
                    'while') or ls.startswith('switch'):
                if ol1: otf.write('\n')
                otf.write(line)

            elif ls.endswith('('):
                if line[0] not in [' '] or (len(ls.split()) > 1
                                            and '=' not in line):
                    if ol2: otf.write('\n')
                    if ol1: otf.write('\n')
                    otf.write('//' + ('-' * 78) + '\n')
                    otf.write(line)
                    otf.write('//' + ('-' * 78) + '\n')

            elif ls.startswith('break'):
                otf.write(line)
                otf.write('\n')

            else:
                otf.write(line)
예제 #31
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)
예제 #32
0
파일: cons.py 프로젝트: chyser/bin
def main(argv):
#------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [], "")

    if not args:
        args = machs.keys()

    for m in args:
        if m not in machs:
	    print "unknown machine", m
	    continue

        print "Opening", m
	session = oss.r("qdbus org.kde.konsole /Konsole newSession", '$').strip()
        s = oss.r("qdbus org.kde.konsole /Sessions/%s setTitle 1 %s" % (session, m), '|')
        if s.strip():
            print s.rstrip()

        s = oss.r('qdbus org.kde.konsole /Sessions/%s sendText "ssh %s"' % (session, m), '|')
        if s.strip():
            print s.rstrip()

        s = oss.r('~/bin/qdsendnl %s' % session, '|')
        if s.strip():
            print s.rstrip()

        for cmd in machs[m]:
    	    if cmd:
	        s = oss.r('qdbus org.kde.konsole /Sessions/%s sendText "%s"' % (session, cmd), '|')
                if s.strip():
                    print s.rstrip()
	    s = oss.r('~/bin/qdsendnl %s' % session, '|')
            if s.strip():
                print s.rstrip()
예제 #33
0
파일: mcp.py 프로젝트: chyser/bin
def main(argv):
    #-------------------------------------------------------------------------------
    """ usage: mcp [options]
        copies files that have changed in monotone

        options:
            -d | --disp   : display only (no copy)
            -f | --force  : force copy of everything
            -u | --update : update from monotone
    """
    args, opts = oss.gopt(oss.argv[1:], [('d', 'disp'), ('f', 'force'),
                                         ('u', 'update')], [], None)

    db = McpDb(opts.disp)

    if opts.update:
        args = []
        v = oss.r('mtn status', '|')

        for line in v[:-1].split('\n'):
            if line.startswith('  patched') or line.startswith('  added'):
                d, fl = line.split()
                args.append(fl)

        if opts.force is None:
            args = db.whatChanged(args)
    else:
        args = db.checkAll()

    for a in args:
        if opts.disp is None:
            print "pscp -pw kibsop) %s [email protected]:work/sdc.hpl.hp.com/eucalyptus/%s" % (
                a, a)
            oss.r(
                "pscp -pw kibsop) %s [email protected]:work/sdc.hpl.hp.com/eucalyptus/%s"
                % (a, a))
        else:
            print a

    oss.exit(0)
예제 #34
0
파일: beautify.py 프로젝트: chyser/bin
    def run(self, fn, force=False):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        oss.r('indent1.exe ' + self.indentOptions + ' ' + fn)
        return
        bfn = self.makeBU(fn, force)

        inf = open(bfn, 'rU')
        otf = open(fn, 'w')

        ol2 = ol1 = ls = None

        for line in inf:
            ol2 = ol1
            ol1 = ls
            ls = line.strip()

            if not ls:
                otf.write('\n')
                continue

            if ls.startswith('if') or ls.startswith('for') or ls.startswith('while') or ls.startswith('switch'):
                if ol1: otf.write('\n')
                otf.write(line)

            elif ls.endswith('('):
                if line[0] not in [' '] or (len(ls.split()) > 1 and '=' not in line):
                    if ol2: otf.write('\n')
                    if ol1: otf.write('\n')
                    otf.write('//' + ('-'*78) +'\n')
                    otf.write(line)
                    otf.write('//' + ('-'*78) +'\n')

            elif ls.startswith('break'):
                otf.write(line)
                otf.write('\n')

            else:
                otf.write(line)
예제 #35
0
파일: cfd.py 프로젝트: chyser/bin
def main(argv):
    #-------------------------------------------------------------------------------
    """ usage: cfd.py [options] <file_name> [<filename> ...]

    options:
        -n | --nocheck     : do not check for CVS root

    displays diffs for files versus top of truck for either a CVS or monotone
    archive
    """
    args, opts = oss.gopt(argv[1:], [('n', 'nocheck')], [], main.__doc__)

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

        cmd = r"C:\bin\cvs.exe diff %s"
    else:
        cmd = "mtn diff --context  %s"

    for arg in args:
        oss.r(cmd % arg)

    oss.exit(0)
예제 #36
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)
예제 #37
0
파일: mycvs.py 프로젝트: chyser/bin
    def create(self, args, opts):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if not self.cvsup:
            print('CVS Archive "%s" is down' % self.root, file=oss.stderr)
            return

        name = args[0] if args else oss.basename(oss.pwd())

        if not self.root.startswith(':pserver:'):
            if oss.exists(self.root + '/' + name):
                if opts.force:
                    pass
                else:
                    print('CVS Archive "%s" exists' % name, file=oss.stderr)
                    return

        msg = opts.msg if opts is not None else 'Initial Checkin: ' + name

        questionable = set([ '*' + ext for ext in self.QuestionableExtensions])
        binaries = set([ '*' + ext for ext in self.BinExts])
        il = "-I! " + ' '.join([ '-I "%s"' % pat for pat in (self.IgnorePatterns | questionable | binaries)])
        oss.r(self.exe + ' import -m"%s" %s %s %s %s1' % (msg, il, name, name, name))

        self.co(None, opts)
예제 #38
0
파일: update_myedit.py 프로젝트: chyser/bin
def main(argv):
    #-------------------------------------------------------------------------------
    """ usage:
    """
    args, opts = oss.gopt(argv[1:], [('p', 'pause')], [],
                          __doc__ + main.__doc__)

    install_dir = oss.env['MYEDIT_DIRECTORY']
    print('MyEdit installed at: "%s"' % install_dir)
    print('\nUpdating "myedit"')
    oss.cd(install_dir)
    t = oss.r('cvs.exe up -d', '|')
    printResults(t)

    print('\nUpdating "pylib"')
    oss.cd('C:/bin/pylib/pylib')
    t = oss.r('cvs.exe up -d', '|')
    printResults(t)

    print('\nIf MyEdit is running, it must be restarted.')

    if opts.pause:
        raw_input('\n<Hit key to continue>')
    oss.exit(0)
예제 #39
0
def main(argv):
    #-------------------------------------------------------------------------------
    """ usage: mk_cmd_help.py [options] [<file_name> ...]

        options:
            -o | --output    : html file output <default: 'cmd_help.html'

        generate an html output file of the help strings from the specified
        commands

    """
    args, opts = oss.gopt(argv[1:], [], [('o', 'output')],
                          main.__doc__ + __doc__)

    outfile = 'cmd_help.html' if opts.output is None else opts.output

    if len(args) == 0:
        args = oss.ls('*.py')

    title = oss.pwd()

    print("Writing to file: '%s'" % outfile)
    with open(outfile, 'w') as otf:
        otf.write(HTML_BEGIN % (title, title))

        ## make a table of links to prgms details
        links = ['<a href="#{0}">{0}</a>'.format(nm) for nm in args]
        otf.write('<a name="top"><h2>Contents</h2></a>\n')
        otf.write("<center>\n" +
                  utils.makeTable(links, tattr='border="1" width="90%"') +
                  "\n</center>\n\n")
        otf.flush()

        ## make an entry for each prgms details
        for prgm in args:
            print(prgm)
            otf.write('\n\n<hr/>\n')
            otf.write('<a name="{0}">'.format(prgm))
            otf.write('<h2>' + prgm + '</h2></a>\n')
            s = oss.r(prgm + ' --help', '$')
            otf.write('<font size="5"><pre>' + cgi.escape(s) +
                      '</pre></font>\n')
            otf.write('<a href="#top">Top</a>\n')
            otf.flush()
        otf.write(HTML_END)
    oss.exit(0)
예제 #40
0
파일: jbuilder.py 프로젝트: chyser/bin
def compile(javac, srcList, force=False, readOnly=False, stopFirst=True):
#-------------------------------------------------------------------------------
    rc = 0
    for sc in srcList:
        pth, fn = sc.rsplit('\\', 1)
        pth1 = pth.split('\\', 2)[2]

        cdir = BUILD_PATH + '/' + pth1
        oss.mkdirs(cdir)

        fd = fn.rsplit('.', 1)[0]
        nf = cdir + '/' + fd + '.class'
        if force or not oss.exists(nf) or oss.newerthan(sc, nf):
            cmd = javac + " -cp %s -d %s %s" % (CLASS_PATH, BUILD_PATH, sc)

            print(cmd)
            if not readOnly:
                rc = oss.r(cmd)

                if rc and stopFirst:
                    oss.exit(rc)

    return rc
예제 #41
0
def main(argv):
    #------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [], "")

    if not args:
        args = machs.keys()

    for m in args:
        if m not in machs:
            print "unknown machine", m
            continue

        print "Opening", m
        session = oss.r("qdbus org.kde.konsole /Konsole newSession",
                        '$').strip()
        s = oss.r(
            "qdbus org.kde.konsole /Sessions/%s setTitle 1 %s" % (session, m),
            '|')
        if s.strip():
            print s.rstrip()

        s = oss.r(
            'qdbus org.kde.konsole /Sessions/%s sendText "ssh %s"' %
            (session, m), '|')
        if s.strip():
            print s.rstrip()

        s = oss.r('~/bin/qdsendnl %s' % session, '|')
        if s.strip():
            print s.rstrip()

        for cmd in machs[m]:
            if cmd:
                s = oss.r(
                    'qdbus org.kde.konsole /Sessions/%s sendText "%s"' %
                    (session, cmd), '|')
                if s.strip():
                    print s.rstrip()
            s = oss.r('~/bin/qdsendnl %s' % session, '|')
            if s.strip():
                print s.rstrip()
예제 #42
0
파일: jbuilder.py 프로젝트: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    """ usage:
    """
    args, opts = oss.gopt(argv[1:], [('f', 'force'), ('r', 'readonly'), ('m', 'makecmd')], [('c', 'cmdfile')], main.__doc__ + __doc__)

    global BUILD_PATH, CLASS_PATH


    if opts.cmdfile:
        if opts.makecmd and not oss.exists(opts.cmdfile):
            oss.touch(opts.cmdfile)

        with open(opts.cmdfile) as inf:
            dd = yaml.load(inf.read())
            if dd is None:
                dd = {}

            slist = dd['files'] if 'files' in dd else []
            BUILD_PATH = dd['build_path'] if 'build_path' in dd else './class'
            CLASS_PATH = dd['class_path'] if 'class_path' in dd else BUILD_PATH

            if not slist:
                slist = oss.find('.', "*.java")

            if 'cmds' in dd:
                CMDS = dd['cmds']
            else:
                CMDS = ['compile']


        if opts.makecmd:
            oss.mv(opts.cmdfile, opts.cmdfile + '.bak')
            with open(opts.cmdfile, 'w') as otf:
                slist.extend(oss.find('.', "*.java"))

                ## ensure names are unique
                s = set(slist)
                slist = [a for a in s]

                dd['files'] = slist
                otf.write(yaml.safe_dump(dd))

    else:
        CMDS = ['compile']
        slist = oss.find('.', "*.java")

    if args:
        CMDS = args

    rc = 0
    for cmd in CMDS:
        if rc != 0:
            oss.exit(rc)

        if cmd == 'compile':
            rc = compile(JAVAC, slist, opts.force, opts.readonly)

        elif cmd.startswith('run '):
            c = cmd[4:].strip()
            print(c)
            rc = oss.r(c)

        elif cmd == 'vcs_add':
            addToVcs(VCS_ADD, slist)


    oss.exit(0)
예제 #43
0
파일: jbuilder.py 프로젝트: chyser/bin
def addToVcs(vcsAdd, srcList):
#-------------------------------------------------------------------------------
    for f in srcList:
        cmd = vcsAdd + ' ' + str(f)
        print(cmd)
        oss.r(cmd)
예제 #44
0
 def run(self):
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     oss.r(self.cmd)
예제 #45
0
파일: rmtcmds.py 프로젝트: chyser/bin
 def run(mach, cmd, user="", passwd="", timeout=30):
     #-------------------------------------------------------------------------------
     if user: user += "@"
     print "here1"
     oss.r(SSH + " %s%s %s" % (user, mach, cmd))
예제 #46
0
    def _read_input(self, completionListFunc, prompt):
        #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        self.pl = len(prompt)
        self.write(prompt)

        self.historyIdx = 0

        while 1:
            self.update()

            ch = self.screen.readKey()
            key = ch.VirtualKeyCode

            actions = [KEY_MAP[key]] if key in KEY_MAP else WordStarKeyMapping(
                key, self.screen.readKey)
            if not actions:
                actions = self.vi.getKey(key)

            if not actions:
                actions = ['KEY']

            for action in actions:
                ## return key
                if action == 'RET':
                    cmdstr = self.getCmdStr()
                    self.setNewLine()

                    if cmdstr.endswith(self.continuationChar):
                        del self.cmd[-1]
                        return self._read_input(completionListFunc,
                                                self.promptContinue)

                    self.addHistory(cmdstr)
                    return cmdstr

                ## backspace
                elif action == 'BKSP':
                    if self.x != self.pl:
                        #print "\n", self.x, self.pl, "\n"
                        try:
                            del self.cmd[self.x - self.pl - 1]
                        except IndexError:
                            pass
                        self.setCursor(self.x - 1)

                ## up arrow
                elif action == 'UP':
                    cmd = self.getHistory()
                    self.historyIdx += 1
                    self.setCmdStr(cmd, self.pl + len(cmd))

                ## down arrow
                elif action == 'DOWN':
                    self.historyIdx -= 1
                    cmd = self.getHistory()
                    self.setCmdStr(cmd, self.pl + len(cmd))

                ## left arrow
                elif action == 'LEFT':
                    self.setCursor(self.x - 1)

                ## right arrow
                elif action == 'RGHT':
                    self.setCursor(self.x + 1)

                ## home
                elif action == 'HOME':
                    self.setCursor(self.pl)

                ## end
                elif action == 'END':
                    self.setCursor(self.pl + len(self.cmd))

                ## tab (auto completion)
                elif action == 'TAB':

                    ## returns either:
                    ## - none for no matches
                    ## - a str which is the new cmd string
                    ## - a list of choices
                    res = completionListFunc(self, self.getCmdStr())

                    if res is not None:
                        if isinstance(res, (str, unicode)):
                            self.setCmdStr(res, self.pl + len(res))
                        else:
                            x = self.x
                            self.setNewLine()
                            self.write(' '.join(res))
                            self.setNewLine()
                            self.write(self.prompt)
                            self.update()
                            self.setCursor(x)

                elif action == 'RM_EOL':
                    self.cmd = self.cmd[:(self.x - self.pl)]

                elif action == 'DEL_CHAR':
                    try:
                        del self.cmd[self.x - self.pl]
                    except IndexError:
                        pass

                elif action == 'EDITOR':
                    otf = open('/tmp/mysh.txt', 'w')
                    otf.write(self.getCmdStr())
                    otf.close()
                    oss.r('vi /tmp/mysh.txt')
                    inf = open('/tmp/mysh.txt')

                    cmdstr = ' '.join([line[:-1] for line in inf.readlines()])
                    self.clear()
                    self.write(prompt)
                    self.setCmdStr(cmdstr, self.pl)

                elif action == 'NOP':
                    pass

                ## other key
                else:
                    self.addChar(ch.Char)
                    self.setCursor(self.x + 1)
예제 #47
0
파일: smsh.py 프로젝트: chyser/bin
 def RmtCmd2Str(self, cmd, chdir=False):
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     return oss.r(self.mkRmtCmd(cmd, chdir), '|').strip()
예제 #48
0
파일: fileobj.py 프로젝트: chyser/bin
 def Save(self, buf, fullSave=True):
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     LocalFileObject.Save(self, buf)
     if fullSave:
         print("pscp " + self.FileName + " " + self.rmtfile)
         oss.r("pscp " + self.FileName + " " + self.rmtfile)
예제 #49
0
파일: runit.py 프로젝트: chyser/bin
def main(argv):
    #-------------------------------------------------------------------------------
    """
    runit.py [-p] [-b] [-m] [-k] [-x] [-d <PathDir>] <script>
        -p | --pause    : pause after completion
        -b | --build    : generate build style output
        -m | --nomain   : disable calling main
        -k | --nomake   : disable running make
        -x | --nodebug  : disable debug flag
        -a | --absdir   : absolute path given, don't use for wkdir
        -d | --wkdir <PathDir> : directory where program is
        <script>: script to run or 'build'

    runit supports execution of python scripts from within Slickedit.  Since a
    window is created on execution (and is destroyed upon completion), console
    programs need to block on user input to allow execution results to be
    seen.  -p does this.  Also, exceptions often cause the blocking code to be
    bypassed, such that errors cannot be seen at all.  Even when visible, the
    default dump format is not easily parsed by editors.  -b does this.  Many
    forms of errors can be detected by 'importing' the program without running
    the main code.  -m does this.

    -d or providing the full path in the script names allows local directory
    modules to be found as if the script was run directly from the local
    directory.

    Version 1.0
    """
    args, opt = oss.gopt(argv[1:], [('p', 'pause'), ('b', 'build'),
                                    ('m', 'nomain'), ('k', 'nomake'),
                                    ('x', 'nodebug'), ('a', 'absdir')],
                         [('d', 'wkdir')], main.__doc__)

    oss.echo("die", "/tmp/runit_die")
    time.sleep(2)
    oss.rm("/tmp/runit_die")

    if not args:
        opt.usage(1, "Must supply a program to run")

    prgmName = oss.path(args[0])

    if opt.wkdir is None:
        pdir = prgmName.drive_path
        opt.wkdir = pdir if pdir and opt.absdir else '.'

    if 0:
        thread.start_new_thread(look_out, (1, ))

    global moduleName, fileName, globd

    moduleName = prgmName.name
    fileName = prgmName.drive_path_name + '.py'

    globd = {}
    exec('import sys', globd)

    ## enable local modules to be found
    wd = oss.abspath(opt.wkdir)
    globd['sys'].path.insert(0, wd)

    ## if calling main is disabled, use build semantics
    if opt.nomain:
        opt.build = True

    try:
        ## recreate argv
        globd['sys'].argv = [fileName] + args[1:]

        ## if calling main is disabled, change name
        globd["__name__"] = "__main__" if opt.nomain is None else moduleName

        if opt.nodebug is not None:
            globd["__debug__"] = True

        if opt.build is None:
            print("CmdLine: '%s'" % " ".join(globd['sys'].argv))

        ## run a makefile if it exists
        if opt.nomake is None:
            if oss.exists("make.pmk") or oss.exists("nmake.pmk"):
                oss.r('python C:\\bin\\pmake.py')
            elif oss.exists("makefile"):
                oss.r('make')

        sys.path = globd['sys'].path
        sys.argv = globd['sys'].argv
        reload(oss)

        sys.modules['runit'] = sys.modules['__main__']
        try:
            sys.modules['__main__'] = __import__(moduleName)
        except ImportError:
            print(sys.path, file=oss.stderr)

        try:
            execfile(sys.modules['runit'].fileName, sys.modules['runit'].globd)
        except SystemExit:
            pass

        if opt.pause and not opt.build:
            print("-- continue --")
            sys.stdin.readline()

    except Exception:
        if opt.build:
            ## print error message(s) in form many editors can parse
            t, v, tb = sys.exc_info()

            traceback.print_exc()

            print(traceback.extract_tb(tb))

            tbl = traceback.extract_tb(tb)[-1]
            s = traceback.format_exception_only(t, v)

            err = "".join(s)

            if s[0].find('File') != -1:
                l = s[0].split()
                print("%s(%s):\n" % (l[1].split('"')[1], l[3]), err)
            else:
                print("%s(%d):\n" % (tbl[0], tbl[1]), err)
        else:
            ## standard dump semantics
            traceback.print_exc()
            print("-- continue --")
            sys.stdin.readline()
예제 #50
0
파일: timeit.py 프로젝트: chyser/bin
def timeOneRun(cmd):
#-------------------------------------------------------------------------------
    st = time.time()
    oss.r(cmd)
    et = time.time()
    return et - st
예제 #51
0
파일: rmtcmds.py 프로젝트: chyser/bin
 def cpf(mach, srcFiles, dest, options="", user="", passwd="", timeout=300):
     #-------------------------------------------------------------------------------
     if user: user += "@"
     oss.r(SCP + " %s %s%s:%s %s" % (options, user, mach, srcFiles, dest))
예제 #52
0
파일: fileobj.py 프로젝트: chyser/bin
 def Load(self):
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     print("pscp " + self.rmtfile + " " + self.FileName)
     oss.r("pscp " + self.rmtfile + " " + self.FileName)
     return LocalFileObject.Load(self)