예제 #1
0
파일: sync.py 프로젝트: fossabot/wdfwd
def sync_file(abspath, to_url):
    to_url = ensure_endsep(to_url)
    st = time.time()
    logging.debug('sync_file: %s to %s' % (abspath, to_url))
    os.environ['RSYNC_PASSWORD'] = RSYNC_PASSWD
    dirn = os.path.dirname(abspath)
    fname = os.path.basename(abspath)
    with ChangeDir(dirn):
        cap_call([rsync_path, RSYNC_OPTION, RSYNC_BWLIMIT, fname, to_url])
    logging.debug('sync elapsed {}'.format(time.time() - st))
예제 #2
0
파일: sync.py 프로젝트: fossabot/wdfwd
def sync_files(folder, files, to_url):
    to_url = ensure_endsep(to_url)
    st = time.time()
    logging.debug('sync_files')
    os.environ['RSYNC_PASSWORD'] = RSYNC_PASSWD
    with ChangeDir(folder):
        for _file in files:
            logging.debug(_file)
            cap_call([rsync_path, RSYNC_OPTION, RSYNC_BWLIMIT, _file, to_url],
                     2)
    logging.debug('sync elapsed {}'.format(time.time() - st))
예제 #3
0
def setup_module(mod):
    # if get_service() is not None and exe_exist():
    # os.chdir('wdfwd/test_dist')
    # call('wdfwd_svc.exe stop')
    # call('wdfwd_svc.exe remove')
    # os.chdir('../..')

    # test build
    path = os.path.join(BASE_DIR, 'test_dist')
    if os.path.isdir(path):
        shutil.rmtree(path)
    with ChangeDir('wdfwd'):
        cap_call('python setup.py py2exe -d test_dist')
        assert os.path.isdir(path)
예제 #4
0
파일: test_sync.py 프로젝트: haje01/wdfwd
def test_rsync(capsys):
    assert os.path.isfile(rsync_path)
    cap_call([rsync_path], 0, False, True)
    outerr = capsys.readouterr()
    assert "version" in outerr[0]
    assert "" in outerr[1]

    # test return
    assert not _cap_call([rsync_path + '~'], 0, False)

    # test retry
    with pytest.raises(CalledProcessError):
        cap_call([rsync_path+'~'], 2, False, True)
    outerr = capsys.readouterr()
    assert "rsync.exe~" in outerr[0]
예제 #5
0
def test_rsync(capsys):
    assert os.path.isfile(rsync_path)
    cap_call([rsync_path], 0, False, True)
    outerr = capsys.readouterr()
    assert "version" in outerr[0]
    assert "" in outerr[1]

    # test return
    assert not _cap_call([rsync_path + '~'], 0, False)

    # test retry
    with pytest.raises(CalledProcessError):
        cap_call([rsync_path + '~'], 2, False, True)
    outerr = capsys.readouterr()
    assert "rsync.exe~" in outerr[0]
예제 #6
0
파일: sync.py 프로젝트: fossabot/wdfwd
def sync_folder(folder, to_url, remove_src=False):
    to_url = ensure_endsep(to_url)
    st = time.time()
    logging.debug('sync_folder')
    os.environ['RSYNC_PASSWORD'] = RSYNC_PASSWD
    # sync dail tables
    with ChangeDir(folder):
        cmd = [
            rsync_path, RSYNC_OPTION, RSYNC_EXCLUDE, RSYNC_EXCLUDE2,
            RSYNC_BWLIMIT
        ]
        if remove_src:
            cmd.append(RSYNC_REMOVE)
        cmd += ['.', to_url]
        # if fail, retry 5 times
        cap_call(cmd, 5)
    logging.debug('sync elapsed {}'.format(time.time() - st))
예제 #7
0
def test_basic():
    # check cfg
    cfg_path = os.path.join(BASE_DIR, 'tests', 'cfg_service.yml')
    os.environ['WDFWD_CFG'] = cfg_path
    cfg = get_config()
    appc = cfg['app']
    assert appc['service']['name'] == 'wdfwd_test'

    # test service isntall
    with ChangeDir('wdfwd', 'test_dist'):
        cap_call('wdfwd_svc.exe install')

        # test start
        cap_call('wdfwd_svc.exe start')
        svc = get_service()
        assert svc is not None
        assert svc.Status == 'OK'
예제 #8
0
def teardown_module(mod):
    # uninstall service
    svc = get_service()
    if svc is not None and exe_exist():
        with ChangeDir(BASE_DIR, 'test_dist'):
            if not TEARDOWN_KILL:
                cap_call('wdfwd_svc.exe stop')
            else:
                time.sleep(3)
                cap_call('taskkill /F /PID ' + str(svc.ProcessId))
            cap_call('wdfwd_svc.exe remove')