Пример #1
0
def image_comp(item):
    pdflatex["-shell-escape", item] & FG
    print("Converting", item)
    convert[item.with_suffix(".svg"),
            item.with_suffix(".png")] & FG

    delete(item.with_suffix(".log"),
           item.with_suffix(".aux"),
           )
Пример #2
0
    def main(self):
        delete(local.cwd // "*.egg-info", "build", "dist")

        if self.upload:
            local.python("setup.py", "register")
        
        local.python("setup.py", "sdist", "--formats=zip,gztar", "bdist_wininst", "--plat-name=win32", 
            "upload" if self.upload else None)
        
        delete(local.cwd // "*.egg-info", "build")
Пример #3
0
 def test_append(self):
     delete('nohup.out')
     output = echo['This is output']
     output & NOHUP
     time.sleep(.2)
     assert self.read_file('nohup.out') == 'This is output\n'
     output & NOHUP
     time.sleep(.2)
     assert self.read_file('nohup.out') == 'This is output\n'*2
     delete('nohup.out')
Пример #4
0
 def test_append(self):
     delete('nohup.out')
     output = echo['This is output']
     output & NOHUP
     time.sleep(.2)
     self.assertEqual(self.read_file('nohup.out'), 'This is output\n')
     output & NOHUP
     time.sleep(.2)
     self.assertEqual(self.read_file('nohup.out'), 'This is output\n'*2)
     delete('nohup.out')
Пример #5
0
    def main(self, src, dst):
        if local.path(dst).exists():
            if not self.overwrite:
                logger.debug("Oh no! That's terrible")
                raise ValueError("Destination already exists")
            else:
                delete(dst)

        logger.debug("I'm going to copy %s to %s", src, dst)
        copy(src, dst)
        logger.debug("Great success")
Пример #6
0
 def test_slow(self):
     delete('nohup.out')
     sp = bash['slow_process.bash']
     sp & NOHUP
     time.sleep(.5)
     self.assertEqual(self.read_file('slow_process.out'), 'Starting test\n1\n')
     self.assertEqual(self.read_file('nohup.out'), '1\n')
     time.sleep(1)
     self.assertEqual(self.read_file('slow_process.out'), 'Starting test\n1\n2\n')
     self.assertEqual(self.read_file('nohup.out'), '1\n2\n')
     time.sleep(2)
     delete('nohup.out', 'slow_process.out')
Пример #7
0
 def test_slow(self):
     delete('nohup.out')
     sp = bash['slow_process.bash']
     sp & NOHUP
     time.sleep(.5)
     assert self.read_file('slow_process.out') == 'Starting test\n1\n'
     assert self.read_file('nohup.out') == '1\n'
     time.sleep(1)
     assert self.read_file('slow_process.out') == 'Starting test\n1\n2\n'
     assert self.read_file('nohup.out') == '1\n2\n'
     time.sleep(2)
     delete('nohup.out', 'slow_process.out')
Пример #8
0
    def main(self):
        delete(local.cwd // "*.egg-info", "build", "dist")

        #if self.upload:
        #    local.python("setup.py", "register")

        local.python("setup.py", "sdist", "--formats=zip,gztar", "bdist_wininst", "--plat-name=win32")

        delete(local.cwd // "*.egg-info", "build")

        if self.upload:
            if twine is None:
                print("Twine not installed, cannot securly upload. Install twine.")
            else:
                twine['upload','dist/*'] & FG
Пример #9
0
    def test_copy_move_delete(self):
        from plumbum.cmd import touch

        with local.tempdir() as dir:
            (dir / "orog").mkdir()
            (dir / "orog" / "rec").mkdir()
            for i in range(20):
                touch(dir / "orog" / ("f%d.txt" % (i,)))
            for i in range(20,40):
                touch(dir / "orog" / "rec" / ("f%d.txt" % (i,)))

            move(dir / "orog", dir / "orig")

            s1 = sorted(f.name for f in (dir / "orig").walk())

            copy(dir / "orig", dir / "dup")
            s2 = sorted(f.name for f in (dir / "dup").walk())
            assert s1 == s2

            with SshMachine("localhost") as rem:
                with rem.tempdir() as dir2:
                    copy(dir / "orig", dir2)
                    s3 = sorted(f.name for f in (dir2 / "orig").walk())
                    assert s1 == s3

                    copy(dir2 / "orig", dir2 / "dup")
                    s4 = sorted(f.name for f in (dir2 / "dup").walk())
                    assert s1 == s4

                    copy(dir2 / "dup", dir / "dup2")
                    s5 = sorted(f.name for f in (dir / "dup2").walk())
                    assert s1 == s5

                    with SshMachine("localhost") as rem2:
                        with rem2.tempdir() as dir3:
                            copy(dir2 / "dup", dir3)
                            s6 = sorted(f.name for f in (dir3 / "dup").walk())
                            assert s1 == s6

                            move(dir3 / "dup", dir / "superdup")
                            assert not (dir3 / "dup").exists()

                            s7 = sorted(f.name for f in (dir / "superdup").walk())
                            assert s1 == s7

                            # test rm
                            delete(dir)
Пример #10
0
    def test_copy_move_delete(self):
        from plumbum.cmd import touch

        with local.tempdir() as dir:
            (dir / "orog").mkdir()
            (dir / "orog" / "rec").mkdir()
            for i in range(20):
                touch(dir / "orog" / ("f%d.txt" % (i,)))
            for i in range(20,40):
                touch(dir / "orog" / "rec" / ("f%d.txt" % (i,)))

            move(dir / "orog", dir / "orig")

            s1 = sorted(f.basename for f in (dir / "orig").walk())

            copy(dir / "orig", dir / "dup")
            s2 = sorted(f.basename for f in (dir / "dup").walk())
            self.assertEqual(s1, s2)

            with SshMachine("localhost") as rem:
                with rem.tempdir() as dir2:
                    copy(dir / "orig", dir2)
                    s3 = sorted(f.basename for f in (dir2 / "orig").walk())
                    self.assertEqual(s1, s3)

                    copy(dir2 / "orig", dir2 / "dup")
                    s4 = sorted(f.basename for f in (dir2 / "dup").walk())
                    self.assertEqual(s1, s4)

                    copy(dir2 / "dup", dir / "dup2")
                    s5 = sorted(f.basename for f in (dir / "dup2").walk())
                    self.assertEqual(s1, s5)

                    with SshMachine("localhost") as rem2:
                        with rem2.tempdir() as dir3:
                            copy(dir2 / "dup", dir3)
                            s6 = sorted(f.basename for f in (dir3 / "dup").walk())
                            self.assertEqual(s1, s6)

                            move(dir3 / "dup", dir / "superdup")
                            self.assertFalse((dir3 / "dup").exists())

                            s7 = sorted(f.basename for f in (dir / "superdup").walk())
                            self.assertEqual(s1, s7)

                            # test rm
                            delete(dir)
Пример #11
0
Файл: build.py Проект: C4rt/rpyc
    def main(self):
        delete("build", "dist", "MANIFEST", local.cwd // "*.egg-info")

        # generate zip, tar.gz, and win32 installer
        if self.publish:
            print("registering...")
            local.python("setup.py", "register")
            print("uploading zip and tar.gz")
            local.python("setup.py", "sdist", "--formats=zip,gztar", "upload")
            print("uploading win installer")
            local.python("setup.py", "bdist_wininst", "--plat-name=win32", "upload")
        else:
            local.python("setup.py", "sdist", "--formats=zip,gztar")
            local.python("setup.py", "bdist_wininst", "--plat-name=win32")
    
        delete("build", local.cwd // "*.egg-info")
        print("Built", [f.basename for f in local.cwd / "dist"])
Пример #12
0
    def test_redir(self):
        delete('nohup_new.out')
        output = echo['This is output']

        output & NOHUP(stdout = 'nohup_new.out')
        time.sleep(.2)
        assert self.read_file('nohup_new.out') == 'This is output\n'
        delete('nohup_new.out')

        (output > 'nohup_new.out') & NOHUP
        time.sleep(.2)
        assert self.read_file('nohup_new.out') == 'This is output\n'
        delete('nohup_new.out')

        output & NOHUP
        time.sleep(.2)
        assert self.read_file('nohup.out') == 'This is output\n'
        delete('nohup.out')
Пример #13
0
def test_makeSupportScriptStache():
    delete('xyz')
    assert makeSupportScriptStache(stacheDir='xyz').endswith('xyz')
    assert ls('xyz').split()==['RSrun.2.7.min.js', 'glow.2.7.min.js', 'ide.css', 'jquery-ui.custom.css', 'jquery-ui.custom.min.js', 'jquery.min.js']
    delete('xyz')
Пример #14
0
    def main(self, filename):
        filename = cli.ExistingFile(filename)
        outname = local.cwd / (ROSTER_FILE if self.roster else STUDENTS_FILE)

        date = datetime.now().date()
        semester = 'Spring' if date.month < 5 else 'Summer' if date.month < 8 else 'Fall'

        with open(str(outname),'w') as f:
            out = ft.partial(print,file=f)
            outtable = ft.partial(out,sep=' & ',end=' \\\\\\hline\n')

            students = pd.read_csv(str(filename),sep='\t')
            students = students[pd.notnull(students[EID_NAME])]

            out(START)

            lst = ['']*(1 if self.roster else self.number)
            printed = False

            def splitnames(row):
                row['Lastname'], row['Firstnames'] = row[STUDENT_NAME].title().split('; ')
                row['Firstname'] = row['Firstnames'].split()[0].strip()
                row['NiceName'] = row['Firstname'] + ' ' + row['Lastname']
                return row

            def printrow(row):
                outtable(row['NiceName'],row[EID_NAME],*lst)

            if self._schedule:
                labinfo = pd.read_csv(str(self._schedule),index_col=0)

            for val in sorted(set(students['Unique'])):
                if printed:
                    out(r'\newpage')
                else:
                    printed = True
                one_class = students[students['Unique']==val]
                class_header = '{} \quad {} {} -- {} students'.format(int(val), semester, date.year, len(one_class.index))
                if self._schedule:
                    info = labinfo.loc[int(val)]
                    class_header += ' \quad ' + info['weekday'].upper() + '@' + str(info['starting hour'])
                out(r'''
            \begin{center}

            {\bfseries\large''',class_header,(ROSTTABLEHEAD if self.roster else TABLEHEAD(self.number)))

                one_class = one_class.apply(splitnames,axis=1)
                one_class.apply(printrow,axis=1)

                out('''\\end{tabular}
            \end{center}''')

            out('''
            \end{document}
            ''')

        pdflatex[outname] & FG
        delete(outname,
               outname.with_suffix('.log'),
               outname.with_suffix('.aux'))
        print("Created", outname.with_suffix('.pdf'))
Пример #15
0
def test_createTestPy(timestamp=''):
    "confirm existence of 'test.py'"
    delete('test.py')
    createTestPy()
    assert open('test.py').read().strip().startswith('print(interval)')
    delete('test.py')
Пример #16
0
def test_srcFromFileName():
    """confirm that srcFromFilename has the right content"""
    delete('test.py')
    createTestPy()
    assert srcFromFileName('test.py').strip().startswith('def GlowMe')
Пример #17
0
 def do_cleanup(self):
     """
     cleanup
     """
     delete(self.tempdir)
Пример #18
0
def test_prepareHTMLdir():
     delete('xyz')
     prepareHTMLdir('xyz') 
     assert('xyz' in ls().strip())
     delete('xyz')