コード例 #1
0
ファイル: kraken.py プロジェクト: CanalTP/fabric_navitia
def swap_data_nav(instance, force=False):
    """ swap old/new data.nav.lz4, only if new is still in temp directory
    """
    plain_target = get_real_instance(instance).target_lz4_file
    temp_target = os.path.join(os.path.dirname(plain_target), 'temp', os.path.basename(plain_target))
    if exists(plain_target):
        if exists(temp_target) and \
           (force or (files.getmtime(temp_target) > files.getmtime(plain_target))):
            swap_temp = os.path.join(os.path.dirname(temp_target), 'x')
            files.move(plain_target, swap_temp)
            files.move(temp_target, plain_target)
            files.move(swap_temp, temp_target)
    elif exists(temp_target):
        files.move(temp_target, plain_target)
コード例 #2
0
def swap_data_nav(instance, force=False):
    """ swap old/new data.nav.lz4, only if new is still in temp directory
    """
    plain_target = get_real_instance(instance).target_lz4_file
    temp_target = os.path.join(os.path.dirname(plain_target), 'temp', os.path.basename(plain_target))
    if exists(plain_target):
        if exists(temp_target) and \
           (force or (files.getmtime(temp_target) > files.getmtime(plain_target))):
            swap_temp = os.path.join(os.path.dirname(temp_target), 'x')
            files.move(plain_target, swap_temp)
            files.move(temp_target, plain_target)
            files.move(swap_temp, temp_target)
    elif exists(temp_target):
        files.move(temp_target, plain_target)
コード例 #3
0
ファイル: test_files.py プロジェクト: 26lights/fabtools
def test_move(mock_run):
    from fabtools.files import move
    move('/tmp/src', '/tmp/dst')
    mock_run.assert_called_with('/bin/mv /tmp/src /tmp/dst')
コード例 #4
0
ファイル: test_files.py プロジェクト: zloy531/fabtools3
def test_move(mock_run):
    from fabtools.files import move
    move('/tmp/src', '/tmp/dst')
    mock_run.assert_called_with('/bin/mv /tmp/src /tmp/dst')