Skip to content

Commit

Permalink
Fixing os.path -> posixpath
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Guimaraes committed Jun 26, 2015
1 parent 8c274ee commit f8d25c6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
9 changes: 5 additions & 4 deletions perfkitbenchmarker/benchmark_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""Container for all data required for a benchmark to run."""

import logging
import os
import pickle

from perfkitbenchmarker import disk
Expand Down Expand Up @@ -93,8 +92,10 @@
'os_type is "rhel". In general if two OS\'s use the same package manager, '
'and are otherwise very similar, the same os_type should work on both of '
'them.')
flags.DEFINE_string('scratch_dir', '/',
'Directory in the VM where scratch disks will be mounted.')
flags.DEFINE_string('scratch_dir', '/scratch',
'Base name for all scratch disk directories in the VM.'
'Upon creation, these directories will have numbers'
'appended to them (for example /scratch0, /scratch1, etc).')


class BenchmarkSpec(object):
Expand Down Expand Up @@ -161,7 +162,7 @@ def __init__(self, benchmark_info):
else:
num_striped_disks = FLAGS.num_striped_disks
for i in range(benchmark_info['scratch_disk']):
mount_point = os.path.join(FLAGS.scratch_dir, 'scratch%d' % i)
mount_point = '%s%d' % (FLAGS.scratch_dir, i)
disk_spec = disk.BaseDiskSpec(
self.scratch_disk_size, self.scratch_disk_type,
mount_point, self.scratch_disk_iops,
Expand Down
17 changes: 9 additions & 8 deletions perfkitbenchmarker/linux_virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import logging
import os
import pipes
import posixpath
import re
import threading
import time
Expand Down Expand Up @@ -788,7 +789,7 @@ def RemoteCommand(self, command,
A tuple of stdout and stderr from running the command.
"""
# Escapes bash sequences
command = command.replace("\'", "\'\\\'\'")
command = command.replace("'", r"'\''")

logging.info('Docker running: %s' % command)
command = "sudo docker exec %s bash -c '%s'" % (self.docker_id, command)
Expand All @@ -811,14 +812,14 @@ def ContainerCopy(self, file_name, container_path='', copy_to=True):

# Everything in vm_util.VM_TMP_DIR is directly accessible
# both in the host and in the container
source_path = os.path.join(CONTAINER_MOUNT_DIR, file_name)
source_path = posixpath.join(CONTAINER_MOUNT_DIR, file_name)
command = 'cp %s %s' % (source_path, container_path)
self.RemoteCommand(command)
else:
if container_path == '':
raise errors.VirtualMachine.RemoteExceptionError('Cannot copy '
'from blank target')
destination_path = os.path.join(CONTAINER_MOUNT_DIR, file_name)
destination_path = posixpath.join(CONTAINER_MOUNT_DIR, file_name)
command = 'cp %s %s' % (container_path, destination_path)
self.RemoteCommand(command)

Expand All @@ -832,12 +833,12 @@ def RemoteCopy(self, file_path, remote_path='', copy_to=True):
"""
if copy_to:
file_name = os.path.basename(file_path)
tmp_path = os.path.join(vm_util.VM_TMP_DIR, file_name)
tmp_path = posixpath.join(vm_util.VM_TMP_DIR, file_name)
self.RemoteHostCopy(file_path, tmp_path, copy_to)
self.ContainerCopy(file_name, remote_path, copy_to)
else:
file_name = os.path.basename(remote_path)
tmp_path = os.path.join(vm_util.VM_TMP_DIR, file_name)
file_name = posixpath.basename(remote_path)
tmp_path = posixpath.join(vm_util.VM_TMP_DIR, file_name)
self.ContainerCopy(file_name, remote_path, copy_to)
self.RemoteHostCopy(file_path, tmp_path, copy_to)

Expand All @@ -853,13 +854,13 @@ def MoveFile(self, target, source_path, remote_path=''):
remote_path: The destination of the file on the TARGET machine, default
is the root directory.
"""
file_name = os.path.basename(source_path)
file_name = posixpath.basename(source_path)

# Copies the file to vm_util.VM_TMP_DIR in source
self.ContainerCopy(file_name, source_path, copy_to=False)

# Moves the file to vm_util.VM_TMP_DIR in target
source_host_path = os.path.join(vm_util.VM_TMP_DIR, file_name)
source_host_path = posixpath.join(vm_util.VM_TMP_DIR, file_name)
target_host_dir = vm_util.VM_TMP_DIR
self.MoveHostFile(target, source_host_path, target_host_dir)

Expand Down
1 change: 0 additions & 1 deletion perfkitbenchmarker/virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ def PrepareVMEnvironment(self):
"""
pass


@abc.abstractmethod
def Install(self, package_name):
"""Installs a PerfKit package on the VM."""
Expand Down

0 comments on commit f8d25c6

Please sign in to comment.