예제 #1
0
def check(config_folder,user):
    crontabs = join(config_folder,'crontabs')
    if not os.path.exists(crontabs):
        os.mkdir(crontabs)
    f = open(join(crontabs,user),'wb')
    f.write(execute.simple('crontab -l -u '+user))
    f.close()
    return ''
예제 #2
0
def check(config_folder, user):
    crontabs = join(config_folder, 'crontabs')
    if not os.path.exists(crontabs):
        os.mkdir(crontabs)
    f = open(join(crontabs, user), 'wb')
    f.write(execute.simple('crontab -l -u ' + user))
    f.close()
    return ''
예제 #3
0
 def test_popen_params(self):
     m = Mock()
     m.Popen.return_value = m.Popeni
     m.Popeni.communicate.return_value = ("", "")
     with Replacer() as r:
         r.replace("execute.Popen", m.Popen)
         simple("something")
     compare(
         m.method_calls,
         [
             (
                 "Popen",
                 ("something",),
                 {"cwd": None, "shell": True, "stderr": STDOUT, "stdout": PIPE, "universal_newlines": True},
             ),
             ("Popeni.communicate", (), {}),
         ],
     )
예제 #4
0
def check(config_folder, junk):
    with open(os.path.join(config_folder, 'os_packages'), 'wb') as out:
        for possible in (
                'dpkg -l',
                'yum list',
                'up2date --showall',
        ):
            if execute.returncode('which ' + possible.split()[0]) != 0:
                continue
            out.write(execute.simple(possible))
            return ''
    return 'Could not find package manager!'
예제 #5
0
def check(config_folder,junk):
    with open(os.path.join(config_folder, 'os_packages'), 'wb') as out:
        for possible in (
            'dpkg -l',
            'yum list',
            'up2date --showall',
            ):
            if execute.returncode('which '+possible.split()[0])!=0:
                continue
            out.write(execute.simple(possible))
            return ''
    return 'Could not find package manager!'
예제 #6
0
파일: init.py 프로젝트: pombredanne/checker
def check(config_folder,daemon):
    inits = join(config_folder,'init')
    if not os.path.exists(inits):
        os.mkdir(inits)
    with open(join(inits,daemon),'wb') as f:
        for row in execute.simple(
            '/usr/sbin/update-rc.d -n -f %s remove'%daemon
            ).split('\n'):
            row = row.strip()
            if row.startswith('Removing'):
                continue
            print >>f,row
            
    return ''
예제 #7
0
    def test_working_directory(self, d):
        dir = d.makedir("a_dir", path=True)
        path = d.write("test.py", "\n".join(("import os", "print os.getcwd()")), path=True)

        # tempdirs on Mac OS X give a different path
        # after you've os.chdir's into them!
        cur = os.getcwd()
        try:
            os.chdir(dir)
            expected = os.getcwd() + "\n"
        finally:
            os.chdir(cur)

        compare(expected, simple(sys.executable + " " + path, cwd=dir))
예제 #8
0
 def test_out_and_err(self, d):
     # without the flushes, the order comes out wrong
     path = d.write(
         "test.py",
         "\n".join(
             (
                 "import sys",
                 "sys.stdout.write('stdout\\n')",
                 "sys.stdout.flush()",
                 "sys.stderr.write('stderr\\n')",
                 "sys.stderr.flush()",
                 "sys.stdout.write('stdout2\\n')",
                 "sys.stdout.flush()",
             )
         ),
         path=True,
     )
     compare("stdout\nstderr\nstdout2\n", simple(sys.executable + " " + path))
예제 #9
0
파일: path.py 프로젝트: pombredanne/checker
def check(config_folder,path):
    
    output = []
    
    path = os.path.abspath(path)
    if not os.path.exists(path):
        return "Does not exist:"+repr(path)
    
    spath = path.split(os.sep)
    target_dir = os.path.join(config_folder,*spath[1:-1])
    if not os.path.exists(target_dir):
        os.makedirs(target_dir)
    tpath = os.path.join(target_dir,spath[-1])
    with open(tpath+'.listing','wb') as f:
        if subprocess.mswindows:
            if os.path.isfile(path):
                cp = 'copy'
            else:
                cp = 'xcopy /I /E /Q /H /R /Y'
            execute.simple('%s "%s" "%s"'%(cp,path,tpath))
            text = execute.simple('dir /q /s "%s"' % path)
            for e in win_row_re.finditer(
                text
                ):
                dir = e.group('dir')
                if dir:
                    print >>f
                    print >>f,dir
                    continue
                if e.group('path')=='..':
                    continue
                print >>f,\
                    e.group('user'),\
                    e.group('path')
        else:
            execute.simple('cp -R %r %r'%(path,target_dir))
            output = execute.simple(
                'LC_COLLATE="C" ls -laR --time-style=+ %r' % path
                )
            for e in unix_row_re.finditer(output):
                if e.group('path')=='..':
                    continue
                if e.group('dirname'):
                    print >>f,e.group('dirname')
                else:
                    print >>f,\
                        e.group('perms'),\
                        e.group('user'),\
                        e.group('group'),\
                        e.group('path')
    return ''
예제 #10
0
def check(config_folder,path):
    return execute.simple(
        'bin'+os.sep+'buildout -o -q',
        cwd=path
        )
예제 #11
0
 def test_args(self, d):
     path = d.write("test.py", "\n".join(("import sys", "print sys.argv")), path=True)
     compare("[%r, 'x=1', '--y=2', 'a', 'b']\n" % path, simple(sys.executable + " " + path + " x=1 --y=2 a b"))
예제 #12
0
def check(config_folder, path):
    return execute.simple('bin' + os.sep + 'buildout -o -q', cwd=path)
예제 #13
0
def check(config_folder,param):
    filename,command = param.split(':',1)
    f = open(join(config_folder,filename),'wb')
    f.write(execute.simple(command))
    f.close()
    return ''
예제 #14
0
def check(config_folder, path):
    execute.simple('svn up -q ' + path)
    return svnexternal_re.sub('', execute.simple('svn status ' + path))
예제 #15
0
파일: svn.py 프로젝트: Simplistix/checker
def check(config_folder,path):    
    execute.simple('svn up -q '+path)
    return svnexternal_re.sub('',execute.simple('svn status '+path))