Beispiel #1
0
def test_call():
    """
    test the call function
    """
    assert call("echo test", nerf=True) == (None, "nerfed", "nerfed")
    assert call("echo test", verbose=True)[0] == 0
    assert call("echo test 1>&2", verbose=True)[0] == 0
Beispiel #2
0
 def running():
     pid = None
     try:
         pid = call(f'lsof -i:{CFG.DYNALITE_PORT} -t')[1].strip()
     except CalledProcessError:
         return None
     try:
         args = call(f'ps -p {pid} -o args=')[1].strip()
     except CalledProcessError:
         return None
     if cmd in args:
         return pid
     return None
Beispiel #3
0
def check_reqs():
    '''
    check requirements
    '''
    installed = call('python3 -m pip freeze')[1].strip().split('\n')
    installed = [tuple(item.split('==')) for item  in installed if '==' in item]
    required = open('requirements.txt').read().strip().split('\n')
    required = [tuple(item.split('==')) if '==' in item else (item, None) for item in required]
    @lru_cache(3)
    def check():
        def match_one(iname, iver, rname, rver=None):
            return (iname == rname and parse_version(iver) >= parse_version(rver or iver))
        def match_any(installed, rname, rver):
            return any([match_one(iname, iver, rname, rver) for iname, iver in installed])
        return [(rname, rver) for rname, rver in required if not match_any(installed, rname, rver)]
    def report(rname, rver):
        version = f'or at version {rver}' if rver else ''
        return f'echo "-> {rname} is not installed {version}"'
    return {
        'name': 'reqs',
        'task_dep': [
            'check:noroot',
        ],
        'actions': [
            report(rname, rver) for rname, rver in check()
        ] + [
            'echo "consider running \'./dodo.py\' or \'sudo pip install -r requirements.txt\'"',
            'false',
        ] if len(check()) else [],
        'uptodate': [
            lambda: len(check()) == 0,
        ],
    }
Beispiel #4
0
 def running():
     mutex.acquire()
     pid = None
     try:
         pid = call(f'lsof -i:{CFG.DYNALITE_PORT} -t')[1].strip()
     except CalledProcessError:
         return None
     finally:
         mutex.release()
     mutex.acquire()
     try:
         args = call(f'ps -p {pid} -o args=')[1].strip()
     except CalledProcessError:
         return None
     finally:
         mutex.release()
     if cmd in args:
         return pid
     return None
Beispiel #5
0
def check_hash(program):
    try:
        call(f'hash {program}')
        return True
    except CalledProcessError:
        return False
Beispiel #6
0
 def creds_check():
     try:
         call('aws sts get-caller-identity')
         return True
     except CalledProcessError:
         return False
Beispiel #7
0
 def uptodate():
     try:
         call('aws sts get-caller-identity')
         return True
     except CalledProcessError:
         return False
Beispiel #8
0
 def uptodate():
     try:
         call('npm outdated')
         return False
     except CalledProcessError:
         return True