Beispiel #1
0
    def close(self):
        """ exit pyradio (and kill player instance) """

        self._no_mute_on_stop_playback()

        # First close the subprocess
        self._stop()

        # Here is fallback solution and cleanup
        if self.connection_timeout_thread is not None:
            self.connection_timeout_thread.cancel()
        if self.delay_thread is not None:
            self.delay_thread.cancel()
        if self.process is not None:
            if platform.startswith('win'):
                try:
                    #subprocess.check_output("Taskkill /PID %d /F" % self.process.pid)
                    #subprocess.Popen(["Taskkill", "/PID", "{}".format(self.process.pid), "/F"])
                    subprocess.Call(['Taskkill', '/PID', '{}'.format(self.process.pid), '/F'])
                except:
                    pass
            else:
                try:
                    os.kill(self.process.pid, 15)
                    self.process.wait()
                except ProcessLookupError:
                    # except:
                    pass
            self.process = None
Beispiel #2
0
def runitt():
    open(pid, 'w').close()
    global variable
    variable=str(variable)
    variablestr=str(variable)
    print('Starting Trade of: ' + variablestr)
    process0='./zenbot.sh trade poloniex.' + variablestr
    subprocess.Popen(process0,shell=True)
    time.sleep(1800)
    print('Starting node kill process)
    process1='sudo killall node'
    subprocess.Call(process1,shell=True)

    print('Starting final sell Of:' + variablestr + ' In Case of Error')
    process2='./zenbot.sh sell --order_adjust_time=1000000000 --sell_pct=100 --markup_pct=0  poloniex.' + variablestr
    proc2 = subprocess.Popen(process2,shell=True)
    proc2.communicate()
    print('Starting final sell Of:' + variablestr + ' In Case of Error')
    process3='./zenbot.sh sell --order_adjust_time=1000000000 --sell_pct=100 --markup_pct=0  poloniex.' + variablestr
    proc3 = subprocess.Popen(process3,shell=True)
    proc3.communicate()
    os.remove(pid)
    print('Done running loop, process file deleted. Waiting for another coin...')
Beispiel #3
0
def run_rosscript(pkg, filename):
    subprocess.Call(['source',
                     '/home/catkin/devel/setup.bash'])  # source workspace path
    run = subprocess.Popen(['rosrun', pkg, filename])
Beispiel #4
0
    def routing(self, channel, message):
        routes = self.redis_conn.hgetall(self.routes_key)
        substitutions = {}
        try:
            substitutions.update(self.env_vars())
        except Exception as ex:
            pass
        message = message.decode()
        substitutions["$message"] = message
        substitutions["$channel"] = channel
        for route_hash, route in routes.items():
            try:
                path = self.pathling_metamodel.model_from_str(route)
                print(path.munge)
                try:
                    # try to do substitutions
                    message = path.munge.template
                    for k, v in substitutions.items():
                        message = message.replace(str(k), str(v))
                        print(message)
                except Exception as ex:
                    print(ex)
                if path.source == channel:
                    if path.send_as == "->":
                        # publish
                        self.redis_conn.publish(path.destination, message)
                    elif path.send_as == ">>":
                        # set key
                        if isinstance(path.destination, str):
                            self.redis_conn.set(path.destination, message)
                        else:
                            self.redis_conn.hmset(
                                path.destination.name, {path.destination.field: message}
                            )
                    elif path.send_as == "--":
                        if self.allow_shell_calls:
                            # strip trailing spaces that may cause subprocess call problems
                            path.destination.call = path.destination.call.strip(" ")
                            path.destination.args = [
                                arg.strip(" ") for arg in path.destination.args
                            ]
                            print("sub dict: ", substitutions)
                            print(
                                "shell call (pre-sub):",
                                path.destination.call,
                                path.destination.args,
                            )
                            # substitutions for shell call and args
                            for k, v in substitutions.items():
                                path.destination.call = path.destination.call.replace(
                                    str(k), str(v)
                                )
                                for i, shell_param in enumerate(path.destination.args):
                                    path.destination.args[i] = shell_param.replace(
                                        str(k), str(v)
                                    )
                            print(
                                "shell call (post-sub):",
                                path.destination.call,
                                path.destination.args,
                            )

                            if "NonblockingCall" in str(path.destination):
                                subprocess.Popen(
                                    [path.destination.call, *path.destination.args]
                                )
                            elif "BlockingCall" in str(path.destination):
                                subprocess.Call(
                                    [path.destination.call, *path.destination.args]
                                )
                        else:
                            print("routing does not allow shell calls")
                            print(path.destination.call, path.destination.args)
            except Exception as ex:
                print(ex)
                pass
Beispiel #5
0
def stopWLAN(wlan):
	if checkWLAN(wlan) == 1:
		subprocess.Call("netsh wlan stop hostednetwork")
Beispiel #6
0
def post_update():
    subprocess.Call('nping -n 3 localhost > nul')
    os.remove('_2excel.exe')
    print("Программа обновилась успешно")
    sys.exit()