Ejemplo n.º 1
0
 def xp_filename(clazz, p, sep=None):
     if host.is_windows():
         return clazz._xp_filename_windows(p, sep=sep)
     elif host.is_unix():
         return clazz._xp_filename_unix(p, sep=sep)
     else:
         host.raise_unsupported_system()
Ejemplo n.º 2
0
 def _git_exe_name(clazz):
     'Return the platform specific name of the git exe.'
     if host.is_unix():
         return 'git'
     elif host.is_windows():
         return 'git.exe'
     else:
         host.raise_unsupported_system()
Ejemplo n.º 3
0
 def site_packages_dir(self):
   if host.is_windows():
     site_packages_dir = path.join(self.user_base_install_dir, 'site-packages')
   elif host.is_unix():
     site_packages_dir = path.join(self.user_base_install_dir, 'lib/python/site-packages')
   else:
     host.raise_unsupported_system()
   return site_packages_dir
Ejemplo n.º 4
0
 def bin_dir(self):
   if host.is_windows():
     bin_dir = path.join(self.user_base_install_dir, 'Scripts')
   elif host.is_unix():
     bin_dir = path.join(self.user_base_install_dir, 'bin')
   else:
     host.raise_unsupported_system()
   return bin_dir
Ejemplo n.º 5
0
  def find_exe_for_python(clazz, python_exe):
    'Find pip executable for a specific python exe'
    bes_python_exe.check_exe(python_exe)

    if host.is_windows():
      result = clazz._find_exe_for_python_windows(python_exe)
    elif host.is_unix():
      result = clazz._find_exe_for_python_unix(python_exe)
    else:
      host.raise_unsupported_system()
    return result
Ejemplo n.º 6
0
 def _determine_stuff(clazz, exe, system):
     if system == host.WINDOWS:
         result, message = clazz._determine_stuff_windows(exe)
     elif system in (host.MACOS, host.LINUX):
         result, message = clazz._determine_stuff_unix(exe)
     else:
         host.raise_unsupported_system(system=system)
     if not result:
         assert message
         raise python_error(
             'Failed to determine python for "{}" - {}'.format(
                 exe, message))
     return result
Ejemplo n.º 7
0
def _find_impl_class():
    from bes.system.host import host
    if host.is_linux():
        from .vmware_app_linux import vmware_app_linux
        return vmware_app_linux
    elif host.is_macos():
        from .vmware_app_macos import vmware_app_macos
        return vmware_app_macos
    elif host.is_windows():
        from .vmware_app_windows import vmware_app_windows
        return vmware_app_windows
    else:
        host.raise_unsupported_system()
Ejemplo n.º 8
0
 def _find_impl_class(system):
     result = None
     if system == host.LINUX:
         from ._detail.python_source_linux import python_source_linux
         result = python_source_linux
     elif system == host.MACOS:
         from ._detail.python_source_macos import python_source_macos
         result = python_source_macos
     elif system == host.WINDOWS:
         from ._detail.python_source_windows import python_source_windows
         result = python_source_windows
     else:
         host.raise_unsupported_system(system=system)
     return result
Ejemplo n.º 9
0
 def _make_read_only_temp_file(self):
     from bes.fs.file_util import file_util
     tmp = self._make_temp_file('this is foo\n')
     print('B4: tmp={} mode={}'.format(tmp, file_util.mode(tmp)))
     import os
     #      os.chmod(tmp, stat.S_IREAD)
     os.chmod(tmp, 0o0400)
     print('AF: tmp={} mode={}'.format(tmp, file_util.mode(tmp)))
     return tmp
     if host.is_unix():
         return file_symlink.resolve('/bin/sh')
     elif host.is_windows():
         return r'C:\Windows\System32\cmd.exe'
     else:
         host.raise_unsupported_system()
Ejemplo n.º 10
0
 def _make_test_program(self):
     tmp_dir = self.make_temp_dir()
     file_util.save(path.join(tmp_dir, 'farm_cli.py'),
                    content=self._FARM_CLI_DOT_PY)
     file_util.save(path.join(tmp_dir, 'fruit_cli_args.py'),
                    content=self._FRUIT_CLI_ARGS_DOT_PY)
     file_util.save(path.join(tmp_dir, 'cheese_cli_args.py'),
                    content=self._CHEESE_CLI_ARGS_DOT_PY)
     unix_program = file_util.save(path.join(tmp_dir, 'farm.py'),
                                   content=self._FARM_DOT_PY)
     if host.is_unix():
         program = unix_program
     elif host.is_windows():
         content = self._FARM_DOT_BAT.format(executable=sys.executable)
         program = file_util.save(path.join(tmp_dir, 'farm.bat'),
                                  content=content)
     else:
         host.raise_unsupported_system()
     return program
Ejemplo n.º 11
0
class test_program_unit_test_true(program_unit_test):

    if host.is_unix():
        _program = program_unit_test.file_path(__file__, 'true.sh')
    elif host.is_windows():
        _program = program_unit_test.file_path(__file__, 'true.bat')
    else:
        host.raise_unsupported_system()

    def test_true(self):
        rv = self.run_program(self._program, ['foo', 'bar'])
        self.assertEqual(0, rv.exit_code)
        self.assert_string_equal_strip('foo bar', rv.output)

    def test_true_raw(self):
        rv = self.run_program_raw(self._program, ['foo', 'bar'])
        self.assertEqual(0, rv.exit_code)
        self.assert_string_equal_strip(b'foo bar', rv.output)
Ejemplo n.º 12
0
#-*- coding:utf-8; mode:python; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*-

from ..system.check import check

from bes.system.host import host
if host.is_macos():
  from .native_package_macos import native_package_macos as native_package
elif host.is_linux():
  from .native_package_linux import native_package_linux as native_package
elif host.is_windows():
  from .native_package_windows import native_package_windows as native_package
else:
  host.raise_unsupported_system()

check.register_class(native_package,
                     name = 'native_package',
                     include_seq = False)