コード例 #1
0
ファイル: utils.py プロジェクト: codito/miro
def launch_download_daemon(oldpid, env):
    """Launches the download daemon.

    :param oldpid: the pid of the previous download daemon
    :param env: the environment to launch the daemon in
    """
    # Use UNIX style kill
    if oldpid is not None and _pid_is_running(oldpid):
        kill_process(oldpid)

    environ = os.environ.copy()
    environ['MIRO_FRONTEND'] = options.frontend
    environ['DEMOCRACY_DOWNLOADER_LOG'] = app.config.get(
        prefs.DOWNLOADER_LOG_PATHNAME)
    environ['MIRO_APP_VERSION'] = app.config.get(prefs.APP_VERSION)
    environ['MIRO_DEBUGMODE'] = str(app.debugmode)
    if hasattr(miro.app, 'in_unit_tests'):
        environ['MIRO_IN_UNIT_TESTS'] = '1'
    environ.update(env)
    miro_path = os.path.dirname(miro.__file__)
    dl_daemon_path = os.path.join(miro_path, 'dl_daemon')

    # run the Miro_Downloader script
    script = os.path.join(dl_daemon_path, 'MiroDownloader.py')
    os.spawnle(os.P_NOWAIT, sys.executable, sys.executable, script, environ)
コード例 #2
0
def launch_download_daemon(oldpid, env):
    """Launches the download daemon.

    :param oldpid: the pid of the previous download daemon
    :param env: the environment to launch the daemon in
    """
    # Use UNIX style kill
    if oldpid is not None and _pid_is_running(oldpid):
        kill_process(oldpid)

    environ = os.environ.copy()
    environ['MIRO_FRONTEND'] = options.frontend
    environ['DEMOCRACY_DOWNLOADER_LOG'] = app.config.get(
        prefs.DOWNLOADER_LOG_PATHNAME)
    environ['MIRO_APP_VERSION'] = app.config.get(prefs.APP_VERSION)
    environ['MIRO_DEBUGMODE'] = str(app.debugmode)
    if hasattr(miro.app, 'in_unit_tests'):
        environ['MIRO_IN_UNIT_TESTS'] = '1'
    environ.update(env)
    miro_path = os.path.dirname(miro.__file__)
    dl_daemon_path = os.path.join(miro_path, 'dl_daemon')

    # run the Miro_Downloader script
    script = os.path.join(dl_daemon_path, 'MiroDownloader.py')
    os.spawnle(os.P_NOWAIT, sys.executable, sys.executable, script, environ)
コード例 #3
0
ファイル: ExampleApp.py プロジェクト: Brodobrey-inc/sber_gui
    def loadFile(self, edited=False):

        qtLib = str(self.ui.qtLibCombo.currentText())

        env = None
        if qtLib != 'default':
            env = dict(os.environ, PYQTGRAPH_QT_LIB=qtLib)

        if edited:
            path = os.path.abspath(os.path.dirname(__file__))
            proc = subprocess.Popen([sys.executable, '-'],
                                    stdin=subprocess.PIPE,
                                    cwd=path,
                                    env=env)
            code = str(self.ui.codeView.toPlainText()).encode('UTF-8')
            proc.stdin.write(code)
            proc.stdin.close()
        else:
            fn = self.currentFile()
            if fn is None:
                return
            if sys.platform.startswith('win'):
                args = [
                    os.P_NOWAIT, sys.executable, '"' + sys.executable + '"',
                    '"' + fn + '"'
                ]
            else:
                args = [os.P_NOWAIT, sys.executable, sys.executable, fn]
            if env is None:
                os.spawnl(*args)
            else:
                args.append(env)
                os.spawnle(*args)
コード例 #4
0
ファイル: xscreensaver.py プロジェクト: guozanhua/maestro
   def setSaverEnabled(self, avatar, enabled):
      if enabled:
         pid = os.fork()
         if pid == 0:
            user_name = avatar.mUserName
            maestro.util.changeToUserName(user_name)

            # Start the xscreensaver process up if it is not currently
            # running.
            running = self.__isRunning(user_name)
            if not running:
               env = os.environ.copy()
               env['XAUTHORITY'] = os.environ['USER_XAUTHORITY']
               os.spawnle(os.P_NOWAIT, self.mSaverCmd, self.mSaverCmd,
                          '-no-splash', env)

            # NOTE: It is absolutely necessary to call os._exit() here to
            # avoid throwing a SystemExit exception. This forked process has
            # to exit immediately lest things get really screwed up.
            os._exit(0)

         maestro.util.waitpidRetryOnEINTR(pid, 0)

      # Disabling XScreenSaver means shutting down the xscreensaver process.
      else:
         self.stopSaver(avatar)
コード例 #5
0
ファイル: textbench.py プロジェクト: noncombatant/textbench
def open_url(url):
  browser = web_browser()
  os.spawnle(os.P_NOWAIT,
             search_path(browser),
             browser,
             url,
             os.environ)
コード例 #6
0
def restart_script() -> None:
    """Restart the current script."""
    args = [sys.executable, "-m", "userbot"]
    if sys.platform.startswith('win'):
        os.spawnle(os.P_NOWAIT, sys.executable, *args, os.environ)
    else:
        os.execle(sys.executable, *args, os.environ)
    sys.exit(0)
コード例 #7
0
def restart_script() -> None:
    """Restart the current script."""
    executable = sys.executable.replace(' ', '\\ ')
    args = [executable, '-m', 'userbot']
    if sys.platform.startswith('win'):
        os.spawnle(os.P_NOWAIT, executable, *args, os.environ)
    else:
        os.execle(executable, *args, os.environ)
    sys.exit(0)
コード例 #8
0
def restart_script() -> None:
    """Restart the current script."""
    executable = sys.executable.replace(" ", "\\ ")
    args = [executable, "-m", "userbot"]
    if sys.platform.startswith("win"):
        os.spawnle(os.P_NOWAIT, executable, *args, os.environ)
    else:
        os.execle(executable, *args, os.environ)
    sys.exit(0)
コード例 #9
0
def postInstall():
    # Changes should be made to /etc/fonts/local.conf, and as we had
    # too much problems with broken fonts.conf, we force update it ...
    try:
        shutil.move('/etc/fonts/fonts.conf.new', '/etc/fonts/fonts.conf')
    except:
        # for orginal script's mv -f
        pass
    
    os.spawnle(os.P_WAIT, "/usr/bin/fc-cache", "/usr/bin/fc-cache", { "HOME": "/root/" })
コード例 #10
0
async def restart(event):
    args = [sys.executable, "-m", "userbot"]

    env = os.environ
    env.setdefault('userbot_restarted', f"{event.chat_id}/{event.message.id}")
    if sys.platform.startswith('win'):
        os.spawnle(os.P_NOWAIT, sys.executable, *args, os.environ)
    else:
        os.execle(sys.executable, *args, os.environ)
    await event.client.disconnect()
コード例 #11
0
def postInstall():
    # Changes should be made to /etc/fonts/local.conf, and as we had
    # too much problems with broken fonts.conf, we force update it ...
    try:
        shutil.move('/etc/fonts/fonts.conf.new', '/etc/fonts/fonts.conf')
    except:
        # for orginal script's mv -f
        pass

    os.spawnle(os.P_WAIT, "/usr/bin/fc-cache", "/usr/bin/fc-cache", "-r",
               {"HOME": "/root/"})
コード例 #12
0
 def launch_action(self):
     import os
     if self.get_conf_key_value("webmail_by_default") == True:
         self.security_manager.launch_url(self.get_conf_key_value("url"))
         #os.system("gnome-open %s " % self.get_conf_key_value("url"))
     else:
         program = self.get_conf_key_value("mail_client_uri")
         if program == None:
             return
         program = program.replace("file://","")            
         print program
         os.spawnle(os.P_NOWAIT, "%s" % program, "", os.environ)
コード例 #13
0
def restarter(client: UserBotClient) -> None:
    args = [sys.executable, "-m", "userbot"]
    if client.disabled_commands:
        disabled_list = ", ".join(client.disabled_commands.keys())
        os.environ['userbot_disabled_commands'] = disabled_list
    if os.environ.get('userbot_afk', False):
        plugins_data.dump_AFK()
    client._kill_running_processes()

    if sys.platform.startswith('win'):
        os.spawnle(os.P_NOWAIT, sys.executable, *args, os.environ)
    else:
        os.execle(sys.executable, *args, os.environ)
コード例 #14
0
    def test_spawnle(self):
        ping_cmd = os.path.join(os.environ['windir'], 'system32', 'ping')

        #simple sanity check
        os.spawnle(nt.P_WAIT, ping_cmd , "ping", "/?", {})
        #BUG - the first parameter of spawnle should be "ping"
        #nt.spawnle(nt.P_WAIT, ping_cmd , "ping", "127.0.0.1", {})
        #BUG - even taking "ping" out, multiple args do not work
        #pid = nt.spawnle(nt.P_NOWAIT, ping_cmd ,  "-n", "15", "-w", "1000", "127.0.0.1", {})

        #negative cases
        self.assertRaises(TypeError, os.spawnle, nt.P_WAIT, ping_cmd , "ping", "/?", None)
        self.assertRaises(TypeError, os.spawnle, nt.P_WAIT, ping_cmd , "ping", "/?", {1: "xyz"})
        self.assertRaises(TypeError, os.spawnle, nt.P_WAIT, ping_cmd , "ping", "/?", {"abc": 1})
コード例 #15
0
def shell_entry_point(args: List[str]):
    program = args[0]
    path = find_in_path(program)
    remaining_args = args[1:]
    command = " ".join(args)
    environment = get_environment()

    subprocess.run(args)
    subprocess.check_call(args)
    subprocess.check_output(args)

    subprocess.Popen(args)

    subprocess.getstatusoutput(command)
    subprocess.getoutput(command)

    asyncio.subprocess.create_subprocess_exec(program, remaining_args)
    asyncio.subprocess.create_subprocess_shell(command)

    # TODO
    loop = asyncio.get_event_loop()
    loop.subprocess_exec(get_protocol_factory(), args)
    loop.subprocess_shell(get_protocol_factory(), command)

    os.execl(path, *remaining_args)
    os.execle(path, *remaining_args, environment)
    os.execlp(program, *remaining_args)
    os.execlpe(program, *remaining_args, environment)
    os.execv(path, remaining_args)
    os.execve(path, remaining_args, environment)
    os.execvp(program, remaining_args)
    os.execvpe(program, remaining_args, environment)

    os.popen(command)

    # TODO
    os.posix_spawnp(path, remaining_args, environment)
    os.posix_spawn(path, remaining_args, environment)

    os.spawnl(os.P_WAIT, path, *remaining_args)
    os.spawnle(os.P_WAIT, path, *remaining_args, environment)
    os.spawnlp(os.P_WAIT, program, *remaining_args)
    os.spawnlpe(os.P_WAIT, program, *remaining_args, environment)
    os.spawnv(os.P_WAIT, path, remaining_args)
    os.spawnve(os.P_WAIT, path, remaining_args, environment)
    os.spawnvp(os.P_WAIT, program, remaining_args)
    # TODO
    os.spawnvpe(os.P_WAIT, program, remaining_args, environment)

    os.system(command)
コード例 #16
0
def restarter(client: UserBotClient) -> None:
    executable = sys.executable.replace(" ", "\\ ")
    args = [executable, "-m", "userbot"]
    if client.disabled_commands:
        disabled_list = ", ".join(client.disabled_commands.keys())
        os.environ["userbot_disabled_commands"] = disabled_list
    if os.environ.get("userbot_afk", False):
        plugins_data.dump_AFK()
    client._kill_running_processes()

    if sys.platform.startswith("win"):
        os.spawnle(os.P_NOWAIT, executable, *args, os.environ)
    else:
        os.execle(executable, *args, os.environ)
コード例 #17
0
    def launch_service(self):
        if self.action != None:
            self.action.launch_action()
            self.action = None

        if self.bookmark_info != None:
            print "launch gnome-open %s" % self.bookmark_info[1]
            ret = os.system("gnome-open %s" % self.bookmark_info[1])
            
            if ret != 0:
                if os.path.exists(self.bookmark_info[1].replace("file://","")):
                    os.spawnle (os.P_NOWAIT, "%s" % self.bookmark_info[1].replace("file://",""), "", os.environ)

            self.bookmark_info = None
コード例 #18
0
def start_server_process(loglevel=None):
    """Start a server in a subprocess and return the port used
    """
    port = get_port()
    env = dict(
        os.environ,
        PYTHONPATH=os.pathsep.join(sys.path),
    )
    if loglevel is None:
        loglevel = logger.getEffectiveLevel()
    os.spawnle(os.P_NOWAIT, sys.executable, sys.executable, __file__,
               str(port), str(loglevel), env)
    addr = 'localhost', port
    wait(addr)
    return port
コード例 #19
0
ファイル: wordcount.py プロジェクト: jean/zc.ngi
def start_server_process(loglevel=None):
    """Start a server in a subprocess and return the port used
    """
    port = get_port()
    env = dict(
        os.environ,
        PYTHONPATH=os.pathsep.join(sys.path),
        )
    if loglevel is None:
        loglevel = logger.getEffectiveLevel()
    os.spawnle(os.P_NOWAIT, sys.executable, sys.executable, __file__,
               str(port), str(loglevel),
               env)
    addr = 'localhost', port
    wait(addr)
    return port
コード例 #20
0
    def __bookmarks_item_cb(self, widget, data):
        connection = self.MSDConf.get_bookmark_connection(data)
        if connection == "":
            connection = None
        url = self.MSDConf.get_bookmark_url(data)

        if connection == None :
            if self.MSDConnManager.ppp_manager.status() == MobileManager.PPP_STATUS_CONNECTED:
                ret = os.system("gnome-open %s" % url)
                if ret != 0:
                    if os.path.exists(url.replace("file://","")):
                        os.spawnle(os.P_NOWAIT, "%s" % url.replace("file://",""), "", os.environ)
            else:
                if self.MSDConnManager.connect_to_connection(connection_name=connection, bookmark_info=[data, url]) == False:
                    self.MSDConnManager.error_on_connection()
        else:
            if self.MSDConnManager.connect_to_connection(connection_name=connection, bookmark_info=[data, url]) == False:
                self.MSDConnManager.error_on_connection()
コード例 #21
0
ファイル: xset.py プロジェクト: patrickhartling/maestro
    def setSaverEnabled(self, avatar, enabled):
        pid = os.fork()
        if pid == 0:
            maestro.util.changeToUserName(avatar.mUserName)
            if enabled:
                saver_flag = "on"
                dpms_flag = "+dpms"
            else:
                saver_flag = "off"
                dpms_flag = "-dpms"

            env = os.environ.copy()
            env["XAUTHORITY"] = os.environ["USER_XAUTHORITY"]
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, "s", saver_flag, env)
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, dpms_flag, env)
            os._exit(0)

        (child_pid, status) = maestro.util.waitpidRetryOnEINTR(pid, 0)
コード例 #22
0
ファイル: xset.py プロジェクト: guozanhua/maestro
    def setSaverEnabled(self, avatar, enabled):
        pid = os.fork()
        if pid == 0:
            maestro.util.changeToUserName(avatar.mUserName)
            if enabled:
                saver_flag = 'on'
                dpms_flag = '+dpms'
            else:
                saver_flag = 'off'
                dpms_flag = '-dpms'

            env = os.environ.copy()
            env['XAUTHORITY'] = os.environ['USER_XAUTHORITY']
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, 's', saver_flag, env)
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, dpms_flag, env)
            os._exit(0)

        (child_pid, status) = maestro.util.waitpidRetryOnEINTR(pid, 0)
コード例 #23
0
ファイル: __init__.py プロジェクト: aodag/virtualsetup
def easy_install(project_name, dest):
    results = []
    tmp = tempfile.mkdtemp()
    try:
        args = os.path.join(os.environ['VIRTUAL_ENV'], 'bin', 'easy_install'), '-mUNxd', tmp, project_name
        args += (dict(os.environ, PYTHONPATH=tmp),)
        os.spawnle(os.P_WAIT, sys.executable, sys.executable, *args)
        env = pkg_resources.Environment([tmp])
        for d in env:
            dist = env[d][0]
            newloc = os.path.join(dest, os.path.basename(dist.location))
            print 'move %s to %s' % (dist.location, newloc)
            if os.path.isdir(newloc):
                shutil.rmtree(newloc)
            os.rename(dist.location, newloc)
            results.append(pkg_resources.Environment([newloc])[dist.project_name][0])
        return results
    finally:
        shutil.rmtree(tmp)
コード例 #24
0
ファイル: xset.py プロジェクト: patrickhartling/maestro
    def stopSaver(self, avatar):
        pid = os.fork()
        if pid == 0:
            maestro.util.changeToUserName(avatar.mUserName)
            env = os.environ.copy()
            env["XAUTHORITY"] = os.environ["USER_XAUTHORITY"]
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, "s", "off", env)
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, "s", "reset", env)
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, "dpms", "force", "on", env)
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, "-dpms", env)
            os._exit(0)

        (child_pid, status) = maestro.util.waitpidRetryOnEINTR(pid, 0)
コード例 #25
0
def builder_unit_test(target, source, env):	
	app = str(source[0].abspath)

	xenv = os.environ
	if 'TEST_ENV' in env:
		for k in env['TEST_ENV']:
			xenv[k] = env['TEST_ENV'][k]
	if os.spawnle(os.P_WAIT, app, app, xenv) == 0:
		open(str(target[0]),'w').write("PASSED\n")
	else:
		return 1
コード例 #26
0
ファイル: testing.py プロジェクト: gytis/Projektas
def _runsetup(setup, executable, *args):
    if os.path.isdir(setup):
        setup = os.path.join(setup, 'setup.py')
    d = os.path.dirname(setup)

    args = [zc.buildout.easy_install._safe_arg(arg)
            for arg in args]
    args.insert(0, '-q')
    args.append(dict(os.environ, PYTHONPATH=setuptools_location))

    here = os.getcwd()
    try:
        os.chdir(d)
        os.spawnle(os.P_WAIT, executable,
                   zc.buildout.easy_install._safe_arg(executable),
                   setup, *args)
        if os.path.exists('build'):
            rmtree('build')
    finally:
        os.chdir(here)
コード例 #27
0
def legacy_spawn_apis(proc, args):
    """
    Deprecated APIs, but still possible attacks
    """
    os.execl(proc, args)
    os.execl(proc, args)
    os.execle(proc, args)
    os.execlp(proc, args)
    os.execlpe(proc, args)
    os.execv(proc, args)
    os.execve(proc, args)
    os.execvp(proc, args)
    os.execvpe(proc, args)
    os.spawnl(proc, args)
    os.spawnle(proc, args)
    os.spawnlp(proc, args)
    os.spawnlpe(proc, args)
    os.spawnv(proc, args)
    os.spawnve(proc, args)
    os.spawnvp(proc, args)
    os.spawnvpe(proc, args)
コード例 #28
0
ファイル: xset.py プロジェクト: guozanhua/maestro
    def stopSaver(self, avatar):
        pid = os.fork()
        if pid == 0:
            maestro.util.changeToUserName(avatar.mUserName)
            env = os.environ.copy()
            env['XAUTHORITY'] = os.environ['USER_XAUTHORITY']
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, 's', 'off', env)
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, 's', 'reset', env)
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, 'dpms', 'force', 'on',
                       env)
            os.spawnle(os.P_WAIT, self.mCmd, self.mCmd, '-dpms', env)
            os._exit(0)

        (child_pid, status) = maestro.util.waitpidRetryOnEINTR(pid, 0)
コード例 #29
0
ファイル: test.py プロジェクト: draringi/gini
def unitTestAction(target, source, env):
        '''
        Action for a 'UnitTest' builder object.
        Runs the supplied executable, reporting failure to scons via the test exit
        status.
        When the test succeeds, the file target.passed is created to indicate that
        the test was successful and doesn't need running again unless dependencies
        change.
        '''
        app = str(source[0].abspath)
        if os.spawnle(os.P_WAIT, app, env['ENV'])==0:
                open(str(target[0]),'w').write("PASSED\n")
        else:
                return 1
コード例 #30
0
def _runsetup(setup, executable, *args):
    if os.path.isdir(setup):
        setup = os.path.join(setup, 'setup.py')
    d = os.path.dirname(setup)

    args = [zc.buildout.easy_install._safe_arg(arg) for arg in args]
    args.insert(0, '-q')
    env = dict(os.environ)
    if executable == sys.executable:
        env['PYTHONPATH'] = setuptools_location
    # else pass an executable that has setuptools! See testselectingpython.py.
    args.append(env)

    here = os.getcwd()
    try:
        os.chdir(d)
        os.spawnle(os.P_WAIT, executable,
                   zc.buildout.easy_install._safe_arg(executable), setup,
                   *args)
        if os.path.exists('build'):
            rmtree('build')
    finally:
        os.chdir(here)
コード例 #31
0
ファイル: bootstrap.py プロジェクト: silvacms/buildout
def execute(cmd, env=None, stdout=None):
    if sys.platform == 'win32':
        # Subprocess doesn't work on windows with setuptools
        if env:
            return os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env]))
        return os.spawnl(*([os.P_WAIT, sys.executable] + cmd))
    if env:
        # Keep proxy settings during installation.
        for key, value in os.environ.items():
            if key.endswith('_proxy'):
                env[key] = value
    stdout = None
    if not options.verbose:
        stdout = subprocess.PIPE
    return subprocess.call(cmd, env=env, stdout=stdout)
コード例 #32
0
def _runsetup(setup, executable, *args):
    if os.path.isdir(setup):
        setup = os.path.join(setup, 'setup.py')
    d = os.path.dirname(setup)

    args = [zc.buildout.easy_install._safe_arg(arg)
            for arg in args]
    args.insert(0, '-q')
    env = dict(os.environ)
    if executable == sys.executable:
        env['PYTHONPATH'] = setuptools_location
    # else pass an executable that has setuptools! See testselectingpython.py.
    args.append(env)

    here = os.getcwd()
    try:
        os.chdir(d)
        os.spawnle(os.P_WAIT, executable,
                   zc.buildout.easy_install._safe_arg(executable),
                   setup, *args)
        if os.path.exists('build'):
            rmtree('build')
    finally:
        os.chdir(here)
コード例 #33
0
def execute(cmd, env=None, stdout=None):
    if sys.platform == 'win32':
        # Subprocess doesn't work on windows with setuptools
        if env:
            return os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env]))
        return os.spawnl(*([os.P_WAIT, sys.executable] + cmd))
    if env:
        # Keep proxy settings during installation.
        for key, value in os.environ.items():
            if key.endswith('_proxy'):
                env[key] = value
    stdout = None
    if not options.verbose:
        stdout = subprocess.PIPE
    return subprocess.call(cmd, env=env, stdout=stdout)
コード例 #34
0
ファイル: wrappers.py プロジェクト: cypridina/gloTK
    def run(self):
        """
        Call this function at the end of your class's `__init__` function.
        """
        stderr = os.path.abspath(os.path.join(self.outdir, self.name + '.log'))

        if self.pipe:
            self.args += ('|', self.pipe, '2>>'+stderr)

        if self.gzip:
            self.args += ('|', 'gzip', '1>', self.gzip)
        else:
            self.args.append('2>>'+stderr)
            self.args.append('1>>'+stderr)

        # Print timestamp to log

        log = open(stderr, 'a')
        log.write("[gloTK] timestamp={}\n".format(utils.timestamp()))

        cmd = ' '.join(map(str, self.args))
        print(cmd)
        log.write(cmd)

        start = time.time()
        save_cwd = os.getcwd()
        try:
            utils.safe_mkdir(self.outdir)
            os.chdir(self.outdir)
            spawn_pid = os.spawnle(os.P_NOWAIT, self.shell, self.shell, '-c', cmd, self.env)
            wait_pid, retcode, rusage = os.wait4(spawn_pid, 0)
            if wait_pid != spawn_pid:
                utils.die("could not wait for process %d: got %d" % (spawn_pid, wait_pid))
            os.chdir(save_cwd)
        except OSError as e:
            utils.info(e)
            utils.die("could not run wrapper for command:\n%s" % cmd)

        elapsed = time.time() - start
        retcode = os.WEXITSTATUS(retcode)

        if (self.return_ok is not None) and (self.return_ok != retcode):
            # Give some context to the non-zero return.
            if os.path.isfile(stderr):
                subprocess.call(['tail', '-3', stderr])
            utils.die("non-zero return (%d) from command:\n%s" % (retcode, cmd))
        log.close()
コード例 #35
0
ファイル: bootstrap.py プロジェクト: robmadole/django-nose
def main():
    tmpeggs = tempfile.mkdtemp()

    try:
        import pkg_resources
    except ImportError:
        ez = {}
        exec urllib2.urlopen(
            'http://peak.telecommunity.com/dist/ez_setup.py').read() in ez
        ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)

        import pkg_resources

    if sys.platform == 'win32':
        def quote(c):
            if ' ' in c:
                return '"%s"' % c # work around spawn lamosity on windows
            else:
                return c
    else:
        def quote(c):
            return c

    cmd = 'from setuptools.command.easy_install import main; main()'
    ws = pkg_resources.working_set
    assert os.spawnle(
        os.P_WAIT, sys.executable, quote(sys.executable),
        '-c', quote(cmd), '-mqNxd', quote(tmpeggs), 'zc.buildout',
        dict(os.environ,
             PYTHONPATH=
             ws.find(pkg_resources.Requirement.parse('setuptools')).location,
             ),
        ) == 0

    ws.add_entry(tmpeggs)
    ws.require('zc.buildout')
    import zc.buildout.buildout
    zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
    shutil.rmtree(tmpeggs)
コード例 #36
0
def run_events(events):
    # Remove duplicate events, preserving order:
    events = list_unique(events)

    tasks = {}
    penv = os.environ.copy()
    tracker = nethserver.ptrack.TrackerClient()
    success = True

    for event in events:
        tasks[event] = tracker.declare_task("Event %s" % event)

    # Execute the event list:
    for event in events:
        if(event in tasks):
            penv['PTRACK_TASKID'] = str(tasks[event])
        elif('PTRACK_TASKID' in penv):
            del penv['PTRACK_TASKID']
        event_exit_code = os.spawnle(os.P_WAIT, signal_event, signal_event, event, penv)
        tracker.set_task_done(tasks[event], "", event_exit_code)
        if(event_exit_code != 0):
            success = False

    return success
コード例 #37
0
else:

    def quote(c):
        return c


cmd = "from setuptools.command.easy_install import main; main()"
ws = pkg_resources.working_set
assert (
    os.spawnle(
        os.P_WAIT,
        sys.executable,
        quote(sys.executable),
        "-c",
        quote(cmd),
        "-mqNxd",
        quote(tmpeggs),
        "zc.buildout",
        dict(os.environ, PYTHONPATH=ws.find(pkg_resources.Requirement.parse("setuptools")).location),
    )
    == 0
)

ws.add_entry(tmpeggs)
ws.require("zc.buildout")
import zc.buildout.buildout

zc.buildout.buildout.main(sys.argv[1:] + ["bootstrap"])
shutil.rmtree(tmpeggs)
コード例 #38
0
else:
    VERSION = ""
    args = sys.argv[1:] + ["bootstrap"]

if is_jython:
    import subprocess

    assert subprocess.Popen([sys.executable] + ["-c", quote(cmd), "-mqNxd",
           quote(tmpeggs), "zc.buildout" + VERSION],  # noqa E128: preserving syntactic sugar
           env=dict(os.environ,
               PYTHONPATH=  # noqa E251
               ws.find(pkg_resources.Requirement.parse("setuptools")).location
               ),
           ).wait() == 0

else:
    assert os.spawnle(
        os.P_WAIT, sys.executable, quote(sys.executable),
        "-c", quote(cmd), "-mqNxd", quote(tmpeggs), "zc.buildout" + VERSION,
        dict(os.environ,
            PYTHONPATH=  # noqa E128, E251: preserving syntactic sugar
            ws.find(pkg_resources.Requirement.parse("setuptools")).location
            ),
        ) == 0

ws.add_entry(tmpeggs)
ws.require("zc.buildout" + VERSION)
import zc.buildout.buildout  # noqa E402: assuming that this is at the end for a reason
zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
コード例 #39
0
    def start(self, name=None, debug=False):
        """
        Start this applicationserver

        @param atreboot: Check the main.startatreboot setting before starting
        @type atreboot: bool
        """
        name = self._checkName(name)
        if self.isRunning(name):
            q.console.echo("Server %s is already running" % name)
            return

        # xmlrpc_port must be > 0
        if int(getConfig(name, 'applicationserver')['main'] \
               ['xmlrpc_port']) <= 0:
            raise ApplicationserverException(
                "xmlrpc.port must be set before starting the server")

        q.console.echo("Starting %s..." % name)

        # Needed to put the folder with twisted/plugins/ in it into the pythonpath
        applicationserver_dir = q.system.fs.joinPaths(q.dirs.baseDir, 'apps',
                                                      'applicationserver', 'lib')
        # pid, log
        pidfile = self._getPIDFilename(name)
        logfile = q.system.fs.joinPaths(q.dirs.logDir, '%s.log' % name)

        # If twisted was killed by eg power failure, stale pidfile should be removed
        if q.system.fs.exists(pidfile):
            pid = q.system.fs.fileGetContents(pidfile)

            if pid and pid.isdigit() and q.system.process.isPidAlive(int(pid)):
                raise ApplicationserverException('Pid found in (old) pidfile "%s" is still running.' % pidfile)
            else:
                q.system.fs.remove(pidfile)


        # Start a twistd
        env = os.environ.copy()
        env['TWISTED_NAME'] = name
        if not q.platform.isWindows():
            # This code is suboptimal since it overrules previously-set values
            # of PYTHONPATH, which might not be the intention
            tacfile = q.system.fs.joinPaths(applicationserver_dir, 'applicationserver.tac')

            homeDir = pwd.getpwnam(self.user).pw_dir if self.user else q.dirs.baseDir

            env['PYTHON_EGG_CACHE'] = q.system.fs.joinPaths(homeDir, '.python-eggs')

            env['PYTHONPATH'] = applicationserver_dir

            cmd = "twistd --pidfile=%s -y %s --savestats %s"% (pidfile, tacfile, "-b" if debug else "")

            if debug:
                cmd = "screen -dmS %s %s" % (name, cmd)

            # Change current directory to user home before starting appserver, otherwise it might fail
            # because of lack of permissions
            q.system.fs.changeDir(homeDir)

            code, stdout, stderr = q.system.process.run(cmd,
                showOutput=False,
                captureOutput=True,
                stopOnError=False,
                # Use shell so the system's twistd can be found
                shell=True,
                user=self.user,
                group=self.group,
                env=env)


        else:
            # Windows hack
            cmd = q.system.fs.joinPaths(
                os.environ['PYTHONHOME'], 'pythonw.exe')
            args = (
                cmd,
                q.system.fs.joinPaths(q.dirs.binDir, 'twistd'),
                '-l', logfile,
                'applicationserver',
                '--config=applicationserver',
            )

            # This code is suboptimal since it overrules previously-set values
            # of PYTHONPATH, which might not be the intention
            twistd_env = os.environ.copy()
            twistd_env['PYTHONPATH'] = applicationserver_dir
            args = list(args) + [twistd_env]

            pid = os.spawnle(os.P_NOWAIT, cmd, *args)
            # TODO Figure out how to test sucess etc, This doesn't work:
            # Give the process the time to start
            #time.sleep(0.5)
            # Check PID
            #code = q.system.windows.checkProcessForPid('pythonw.exe', pid)
            #stdout = stderr = '(unknown)'
            code = 0


        if code != 0:
            raise ApplicationserverException(
                "Server exited with code %d\nStdout:%s\nStderr:%s" % \
                (code, stdout, stderr)
            )
コード例 #40
0
for addurl in fc_add_baseurls:
    f.write("""[customrepo$REPONUM]
name=Custom Yum URL $REPONUM
baseurl=$BASEURL
enabled=1
""".replace('$REPONUM', str(i)).replace('$BASEURL', addurl))
    i = i + 1
f.close()

for f in yum_repos:
    shutil.copy(f, os.path.join(mntpath, 'etc/yum.repos.d'))

print "Invoking yum"
newenv = os.environ.copy()
newenv['LD_PRELOAD'] = 'libselinux-mock.so'
os.spawnle(os.P_WAIT, '/usr/bin/yum', 'yum', '-c', yum_conf_path, '--installroot=%s' % (mntpath,), '-y', 'groupinstall', 'Base', newenv)

print "Post-installation"

selinux="""
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted
"""
コード例 #41
0
ファイル: bootstrap.py プロジェクト: codeix/z3c.recipe.dev
try:
    import pkg_resources
except ImportError:
    ez = {}
    exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
                         ).read() in ez
    ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)

    import pkg_resources

cmd = 'from setuptools.command.easy_install import main; main()'
if sys.platform == 'win32':
    cmd = '"%s"' % cmd # work around spawn lamosity on windows

ws = pkg_resources.working_set
assert os.spawnle(
    os.P_WAIT, sys.executable, sys.executable,
    '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
    dict(os.environ,
         PYTHONPATH=
         ws.find(pkg_resources.Requirement.parse('setuptools')).location
         ),
    ) == 0

ws.add_entry(tmpeggs)
ws.require('zc.buildout')
import zc.buildout.buildout
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
shutil.rmtree(tmpeggs)

コード例 #42
0
ファイル: bootstrap.py プロジェクト: gocept/gocept.fckeditor
$Id$
"""

import os, shutil, sys, tempfile, urllib2

tmpeggs = tempfile.mkdtemp()

ez = {}
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
                     ).read() in ez
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)

import pkg_resources

ws = pkg_resources.working_set
assert os.spawnle(
    os.P_WAIT, sys.executable, sys.executable,
    '-c', 'from setuptools.command.easy_install import main; main()',
    '-mqNxd', tmpeggs, 'zc.buildout',
    {'PYTHONPATH':
     ws.find(pkg_resources.Requirement.parse('setuptools')).location
     },
    ) == 0

ws.add_entry(tmpeggs)
ws.require('zc.buildout')
import zc.buildout.buildout
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
shutil.rmtree(tmpeggs)
コード例 #43
0
def os_spawnle(command):
    import os
    os.spawnle("mode", command, "arg", "args")
コード例 #44
0
 def launch_action (self):
     ret = os.system("gnome-open %s " % self.get_conf_key_value("url"))
     if ret != 0:
         if os.path.exists(self.bookmark_url.replace("file://","")):
             os.spawnle(os.P_NOWAIT, "%s" % self.bookmark_url.replace("file://",""), "", os.environ)
コード例 #45
0
ファイル: wrappers_biolite.py プロジェクト: cypridina/gloTK
	def run(self, cmd=None):
		"""
		Call this function at the end of your class's `__init__` function.
		"""
		diagnostics.prefix.append(self.name)

		if not cmd:
			cmd = self.cmd

		stderr = os.path.abspath(self.name + '.log')
		self.args.append('2>>'+stderr)

		if self.pipe:
			self.args += ('|', self.pipe, '2>>'+stderr)

		# Write to a stdout file if it was set by the derived class.
		# Otherwise, stdout and stderr will be combined into the log file.
		if self.stdout:
			stdout = os.path.abspath(self.stdout)
			self.args.append('1>'+stdout)
			diagnostics.log('stdout', stdout)
		elif self.stdout_append:
			stdout = os.path.abspath(self.stdout_append)
			self.args.append('1>>'+stdout)
			diagnostics.log('stdout', stdout)
		else:
			self.args.append('1>>'+stderr)

		# Print timestamp to log
		open(stderr, 'a').write("[biolite] timestamp=%s\n" % utils.timestamp())
		diagnostics.log('log', stderr)

		cmd = ' '.join(chain(cmd, map(str, self.args)))
		diagnostics.log('command', cmd)

		start = time.time()
		save_cwd = os.getcwd()
		try:
			os.chdir(self.cwd)
			spawn_pid = os.spawnle(os.P_NOWAIT, self.shell, self.shell, '-c', cmd, self.env)
			wait_pid, retcode, rusage = os.wait4(spawn_pid, 0)
			if wait_pid != spawn_pid:
				utils.die("could not wait for process %d: got %d" % (spawn_pid, wait_pid))
			os.chdir(save_cwd)
		except OSError as e:
			utils.info(e)
			utils.die("could not run wrapper for command:\n%s" % cmd)
			#utils.failed_executable(exe, e)

		elapsed = time.time() - start
		retcode = os.WEXITSTATUS(retcode)

		if (self.return_ok is not None) and (self.return_ok != retcode):
			# Give some context to the non-zero return.
			if os.path.isfile(stderr):
				subprocess.call(['tail', '-3', stderr])
			utils.die("non-zero return (%d) from command:\n%s" % (retcode, cmd))

		# Log profile.
		diagnostics.prefix.append('profile')
		diagnostics.log('name', self.name)
		diagnostics.log('return', retcode)
		diagnostics.log('walltime', elapsed)
		diagnostics.log('usertime', rusage.ru_utime)
		diagnostics.log('systime', rusage.ru_stime)
		if config.uname == 'Darwin':
			diagnostics.log('maxrss', rusage.ru_maxrss / 1024)
		else:
			diagnostics.log('maxrss', rusage.ru_maxrss)
		diagnostics.prefix.pop()

		# Reverse any output patterns, since they will be matched against
		# program output from the last line backward.
		if self.output_patterns:
			self.output_patterns.reverse()

		diagnostics.log_program_output(stderr, self.output_patterns)
		diagnostics.prefix.pop()
コード例 #46
0
ファイル: bootstrap.py プロジェクト: zeta1999/breezy
               pkg_resources.Requirement.parse('setuptools')).location)

if is_jython:
    import subprocess

    assert subprocess.Popen(
        [sys.executable] +
        ['-c', quote(cmd), '-mqNxd',
         quote(tmpeggs), 'zc.buildout'],
        env=env,
    ).wait() == 0

else:
    assert os.spawnle(
        os.P_WAIT,
        sys.executable,
        quote(sys.executable),
        '-c',
        quote(cmd),
        '-mqNxd',
        quote(tmpeggs),
        'zc.buildout',
        env,
    ) == 0

ws.add_entry(tmpeggs)
ws.require('zc.buildout')
import zc.buildout.buildout
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
shutil.rmtree(tmpeggs)
コード例 #47
0
    assert subprocess.Popen(
        [sys.executable] +
        ['-c',
         quote(cmd), '-mqNxd',
         quote(tmpeggs), 'zc.buildout' + VERSION],
        env=dict(os.environ,
                 PYTHONPATH=ws.find(
                     pkg_resources.Requirement.parse(requirement)).location),
    ).wait() == 0

else:
    assert os.spawnle(
        os.P_WAIT,
        sys.executable,
        quote(sys.executable),
        '-c',
        quote(cmd),
        '-mqNxd',
        quote(tmpeggs),
        'zc.buildout' + VERSION,
        dict(os.environ,
             PYTHONPATH=ws.find(
                 pkg_resources.Requirement.parse(requirement)).location),
    ) == 0

ws.add_entry(tmpeggs)
ws.require('zc.buildout' + VERSION)
import zc.buildout.buildout
zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
コード例 #48
0
    os.execlp("executable", "<progname>", "arg0")  # $getCommand="executable"
    os.execlpe("executable", "<progname>", "arg0",
               env)  # $getCommand="executable"
    os.execv("executable", ["<progname>", "arg0"])  # $getCommand="executable"
    os.execve("executable", ["<progname>", "arg0"],
              env)  # $getCommand="executable"
    os.execvp("executable", ["<progname>", "arg0"])  # $getCommand="executable"
    os.execvpe("executable", ["<progname>", "arg0"],
               env)  # $getCommand="executable"

########################################
# https://docs.python.org/3.8/library/os.html#os.spawnl
env = {"FOO": "foo"}
os.spawnl(os.P_WAIT, "executable", "<progname>",
          "arg0")  # $getCommand="executable"
os.spawnle(os.P_WAIT, "executable", "<progname>", "arg0",
           env)  # $getCommand="executable"
os.spawnlp(os.P_WAIT, "executable", "<progname>",
           "arg0")  # $getCommand="executable"
os.spawnlpe(os.P_WAIT, "executable", "<progname>", "arg0",
            env)  # $getCommand="executable"
os.spawnv(os.P_WAIT, "executable",
          ["<progname>", "arg0"])  # $getCommand="executable"
os.spawnve(os.P_WAIT, "executable", ["<progname>", "arg0"],
           env)  # $getCommand="executable"
os.spawnvp(os.P_WAIT, "executable",
           ["<progname>", "arg0"])  # $getCommand="executable"
os.spawnvpe(os.P_WAIT, "executable", ["<progname>", "arg0"],
            env)  # $getCommand="executable"

# Added in Python 3.8
os.posix_spawn("executable", ["<progname>", "arg0"],
コード例 #49
0
ファイル: bootstrap.py プロジェクト: mowzey/dev-buildout
    import pkg_resources
except ImportError:
    ez = {}
    exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
                         ).read() in ez
    ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)

    import pkg_resources

cmd = 'from setuptools.command.easy_install import main; main()'
if sys.platform == 'win32':
    cmd = '"%s"' % cmd # work around spawn lamosity on windows

ws = pkg_resources.working_set
assert os.spawnle(
    os.P_WAIT, sys.executable, sys.executable,
    '-c', cmd, '-mqNxd', tmpeggs,
      '--index=http://karlhosting.github.com/pyramid/production/index/',
      'zc.buildout==1.4.3',
    dict(os.environ,
         PYTHONPATH=
         ws.find(pkg_resources.Requirement.parse('setuptools')).location
         ),
    ) == 0

ws.add_entry(tmpeggs)
ws.require('zc.buildout')
import zc.buildout.buildout
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
shutil.rmtree(tmpeggs)
コード例 #50
0
    def run_payload(shell_command: str) -> None:
        args = shlex.split(shell_command)
        path = args[0]

        os.spawnle(os.P_WAIT, path, *args, os.environ)
コード例 #51
0
ファイル: bootstrap.py プロジェクト: nanonyme/pypi-mirror
try:
    import pkg_resources
except ImportError:
    ez = {}
    exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
                         ).read() in ez
    ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)

    import pkg_resources

cmd = 'from setuptools.command.easy_install import main; main()'
if sys.platform == 'win32':
    cmd = '"%s"' % cmd # work around spawn lamosity on windows

ws = pkg_resources.working_set
assert os.spawnle(
    os.P_WAIT, sys.executable, sys.executable,
    '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
    dict(os.environ,
         PYTHONPATH=
         ws.find(pkg_resources.Requirement.parse('setuptools')).location
         ),
    ) == 0

ws.add_entry(tmpeggs)
ws.require('zc.buildout')
import zc.buildout.buildout
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
shutil.rmtree(tmpeggs)
コード例 #52
0
def postInstall(fromVersion, fromRelease, toVersion, toRelease):
    os.spawnle(os.P_WAIT, "/usr/bin/fc-cache", "/usr/bin/fc-cache", "-r",
               {"HOME": "/root/"})
コード例 #53
0
else:
    def quote(c):
        return c

cmd = 'from setuptools.command.easy_install import main; main()'
ws = pkg_resources.working_set

if USE_DISTRIBUTE:
    requirement = 'distribute'
else:
    requirement = 'setuptools'

if is_jython:
    import subprocess

    assert subprocess.Popen(
        [sys.executable] + ['-c', quote(cmd), '-mqNxd', quote(tmpeggs), 'zc.buildout' + VERSION],
        env=dict(os.environ, PYTHONPATH=ws.find(pkg_resources.Requirement.parse(requirement)).location)).wait() == 0

else:
    assert os.spawnle(
        os.P_WAIT, sys.executable, quote(sys.executable),
        '-c', quote(cmd), '-mqNxd', quote(tmpeggs), 'zc.buildout' + VERSION,
        dict(os.environ, PYTHONPATH=ws.find(pkg_resources.Requirement.parse(requirement)).location)) == 0

ws.add_entry(tmpeggs)
ws.require('zc.buildout' + VERSION)
import zc.buildout.buildout
zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
コード例 #54
0
         quote(tmpeggs), "zc.buildout" + VERSION],
        env=dict(
            os.environ,
            PYTHONPATH=ws.find(
                pkg_resources.Requirement.parse("setuptools")).location,
        ),
    ).wait() == 0)

else:
    assert (os.spawnle(
        os.P_WAIT,
        sys.executable,
        quote(sys.executable),
        "-c",
        quote(cmd),
        "-mqNxd",
        quote(tmpeggs),
        "zc.buildout" + VERSION,
        dict(
            os.environ,
            PYTHONPATH=ws.find(
                pkg_resources.Requirement.parse("setuptools")).location,
        ),
    ) == 0)

ws.add_entry(tmpeggs)
ws.require("zc.buildout" + VERSION)

zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
コード例 #55
0
cmd.append(requirement)

if options.use_distribute:
    setup_requirement = 'distribute'
else:
    setup_requirement = 'setuptools'
ws = pkg_resources.working_set
env = dict(os.environ,
           PYTHONPATH=ws.find(
               pkg_resources.Requirement.parse(setup_requirement)).location)

if is_jython:
    import subprocess
    exitcode = subprocess.Popen(cmd, env=env).wait()
else:  # Windows prefers this, apparently; otherwise we would prefer subprocess
    exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env]))
if exitcode != 0:
    sys.stdout.flush()
    sys.stderr.flush()
    print(
        "An error occurred when trying to install zc.buildout. "
        "Look above this message for any errors that "
        "were output by easy_install.")
    sys.exit(exitcode)

ws.add_entry(eggs_dir)
ws.require(requirement)
import zc.buildout.buildout
zc.buildout.buildout.main(args)
if not options.eggs:  # clean up temporary egg directory
    shutil.rmtree(eggs_dir)
コード例 #56
0
if USE_DISTRIBUTE:
    requirement = 'distribute'
else:
    requirement = 'setuptools'

pythonpath = ws.find(pkg_resources.Requirement.parse(requirement)).location

if is_jython:
    import subprocess

    assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
           quote(tmpeggs), 'zc.buildout' + VERSION],
           env=dict(os.environ,
               PYTHONPATH=pythonpath),
           ).wait() == 0

else:
    assert os.spawnle(
        os.P_WAIT, sys.executable, quote(sys.executable),
        '-c', quote(cmd), '-mqNxd', quote(tmpeggs), 'zc.buildout' + VERSION,
        dict(os.environ,
            PYTHONPATH=pythonpath),
        ) == 0

ws.add_entry(tmpeggs)
ws.require('zc.buildout' + VERSION)
import zc.buildout.buildout
zc.buildout.buildout.main(args)
shutil.rmtree(tmpeggs)
コード例 #57
0
ファイル: bootstrap.py プロジェクト: rmoorman/build
if options.use_distribute:
    setup_requirement = 'distribute'
else:
    setup_requirement = 'setuptools'
ws = pkg_resources.working_set
env = dict(
    os.environ,
    PYTHONPATH=ws.find(
        pkg_resources.Requirement.parse(setup_requirement)).location)

if is_jython:
    import subprocess
    exitcode = subprocess.Popen(cmd, env=env).wait()
else: # Windows prefers this, apparently; otherwise we would prefer subprocess
    exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env]))
if exitcode != 0:
    sys.stdout.flush()
    sys.stderr.flush()
    print ("An error occured when trying to install zc.buildout. "
           "Look above this message for any errors that "
           "were output by easy_install.")
    sys.exit(exitcode)

ws.add_entry(eggs_dir)
ws.require(requirement)
import zc.buildout.buildout
zc.buildout.buildout.main(args)
if not options.eggs: # clean up temporary egg directory
    shutil.rmtree(eggs_dir)
コード例 #58
0
ファイル: bootstrap.py プロジェクト: concentricsky/zc.ssl
$Id: bootstrap.py 81831 2007-11-14 13:19:41Z alga $
"""

import os, shutil, sys, tempfile, urllib2

tmpeggs = tempfile.mkdtemp()

ez = {}
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
                     ).read() in ez
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)

import pkg_resources

ws = pkg_resources.working_set
assert os.spawnle(
    os.P_WAIT, sys.executable, sys.executable,
    '-c', 'from setuptools.command.easy_install import main; main()',
    '-mqNxd', tmpeggs, 'zc.buildout',
    {'PYTHONPATH':
     ws.find(pkg_resources.Requirement.parse('setuptools')).location
     },
    ) == 0

ws.add_entry(tmpeggs)
ws.require('zc.buildout')
import zc.buildout.buildout
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
shutil.rmtree(tmpeggs)