예제 #1
0
 def __init__(self):
     # settings.bot.device = u2.connect('RR8M90JGAXR')
     settings.bot.device = u2.connect('0.0.0.0')
     module = __import__("bots.%s" % settings.bot.bank.lower())
     robot = getattr(module, settings.bot.bank.lower())
     self.bank = robot
     settings.bot.pid = self.bank.start()
     print("您的银行应用已经由脚本接管")
     status(settings.bot.serial_no, Status.RUNNING.value)
     self.works_list = []
     self.alive = True
     # self.wait_trans = False
     self.trans_process = False
     self.wait_msg = True
예제 #2
0
 def do_works(self):
     self.bank.remove_float_win()
     while self.alive:
         time.sleep(10)
         res = status(settings.bot.serial_no, Status.RUNNING.value)
         for work in self.works_list:
             print(work)
         if len(self.works_list) > 0:
             print("正在为您执行转账任务,请耐心等待...")
             self.cast_do_transfer(self.works_list.pop(0))
예제 #3
0
def do_status(hw, args):#, output):
    """ Print out the status registers from all of the links.  """
    status_flags = api.status(hw, args.links)
    print(status_flags)
    print_status_header(args.links)#output, args.links)

    for flag, flag_cfg in status_flags.iteritems():
        sys.stdout.write(flag)#output(flag)
        for link in args.links:
            if flag_cfg['links'][link]:
                sys.stdout.write(colored(' * ', 'green'))#output(colored(' * ', 'green'))
            else:
                sys.stdout.write(colored(' E ', 'red'))#output(colored(' E ', 'red'))
        output('\n')
예제 #4
0
def status():
    """
    Get the current status of the API endpoint.
    This method does not require any parameters.
    The response contains a status orject relfecting
    the current status of the called API.
    """
    logger.info('Calling status().')
    response = api.status()
    logger.debug("Received response:\n{}".format(json.dumps(response,
                                                            indent=4)))
    # TODO: The datamodels.Status() use might be overkill. Check later if this is a good idea.
    logger.info("API status is: {}.".format(
        datamodels.Status(response['data']['build_date'])))
예제 #5
0
def do_status(hw, args):#, output):
    """ Print out the status registers from all of the links.  """
    status_flags = api.status(hw, args.links)
    print_status_header(args.links)#output, args.links)

    # get labels of flags
    flags = [x[0] for x in status_flags.values()[0]]

    # Loop over each flag
    for iflag, flag in enumerate(flags):
        sys.stdout.write("%-11s" % flag)
        for link in args.links:
            if status_flags[link][iflag][1]:
                sys.stdout.write(colored(' * ', 'green'))#output(colored(' * ', 'green'))
            else:
                sys.stdout.write(colored(' E ', 'red'))#output(colored(' E ', 'red'))
        sys.stdout.write('\n')
예제 #6
0
파일: cli.py 프로젝트: uwcms/ctp6commander
def do_status(hw, args):  #, output):
    """ Print out the status registers from all of the links.  """
    status_flags = api.status(hw, args.links)
    print_status_header(args.links)  #output, args.links)

    # get labels of flags
    flags = [x[0] for x in status_flags.values()[0]]

    # Loop over each flag
    for iflag, flag in enumerate(flags):
        sys.stdout.write("%-11s" % flag)
        for link in args.links:
            if status_flags[link][iflag][1]:
                sys.stdout.write(colored(
                    ' * ', 'green'))  #output(colored(' * ', 'green'))
            else:
                sys.stdout.write(colored(
                    ' E ', 'red'))  #output(colored(' E ', 'red'))
        sys.stdout.write('\n')
예제 #7
0
def check_pid_status(p_comp, p_pidfile, p_kount=0, p_json=False):
  if os.path.isfile(p_pidfile):
    try:
      with open(p_pidfile, 'r') as f:
        pid = f.readline().rstrip(os.linesep)
      ver = meta.get_ver_plat(p_comp)
      if util.is_pid_running(pid):
        api.status(p_json, p_comp, ver, "running as pid " + str(pid), 0, p_kount)
      else:
        api.status(p_json, p_comp, ver, "not running as pid " + str(pid), 0, p_kount)
    except Exception as e:
      print(str(e))
  else:
    api.status(p_json, p_comp, "", "not running", 0, p_kount)
예제 #8
0
def check_pid_status(p_comp, p_pidfile, p_kount=0, p_json=False):
    if os.path.isfile(p_pidfile):
        ver = meta.get_ver_plat(p_comp)
        rc = os.system("pgrep --pidfile " + p_pidfile + " > /dev/null 2>&1")
        if rc == 0:
            api.status(p_json, p_comp, ver, "running", 0, p_kount)
        else:
            api.status(p_json, p_comp, ver, "not running", 0, p_kount)

        #try:
        #  with open(p_pidfile, 'r') as f:
        #     pid = f.readline().rstrip(os.linesep)
        #  ver = meta.get_ver_plat(p_comp)
        #  if util.is_pid_running(pid):
        #    api.status(p_json, p_comp, ver, "running as pid " + str(pid), 0, p_kount)
        #  else:
        #    api.status(p_json, p_comp, ver, "not running as pid " + str(pid), 0, p_kount)
        #except Exception as e:
        #  print(str(e))
    else:
        api.status(p_json, p_comp, "", "not running", 0, p_kount)
예제 #9
0
 def cast_stop(self):
     self.alive = False
     status(settings.bot.serial_no, Status.STOP.value)
     self.bank.stop()
예제 #10
0
def status():
    api.status()