コード例 #1
0
 def start_all(cls):
     L.info(cls.service_conf)
     try:
         for x in cls.service.values():
             L.info(int(cls.service_conf["kancolle"]))
             #x.start(int(cls.service_conf["kancolle"]))
             p = multiprocessing.Process(target=x.start, args=(int(cls.service_conf["kancolle"]), ))
             p.daemon = True
     except Exception as e:
         L.warning(str(e))
コード例 #2
0
 def get_config(cls, conf=""):
     cls.service_conf = {}
     if conf == "":
         conf = os.path.join(define.APP_BIN, "port.ini")
         L.debug(conf)
     try:
         config = ConfigParser.ConfigParser()
         config.read(conf)
         for section in config.sections():
             for option in config.options(section):
                 cls.service_conf["%s" % option] = config.get(section, option)
     except Exception as e:
         L.warning("error: could not read config file: %s" % e)
コード例 #3
0
 def _service_parse(cls, conf=""):
     result = []
     if conf == "":
         conf = os.path.join(define.APP_SCRIPT, "module.ini")
     try:
         config = ConfigParser.ConfigParser()
         config.read(conf)
         for section in config.sections():
             for option in config.options(section):
                 if config.get(section, option) == str(True):
                     result.append(option)
         return result
     except Exception as e:
         L.warning('error: could not read config file: %s' % e)
         return result
コード例 #4
0
 def register(cls):
     base_dir = define.APP_LIB
     cwd = os.getcwd()
     for fdn in os.listdir(base_dir):
         try:
             if fdn.endswith(".pyc") or fdn.endswith(".py"):
                 pass
             else:
                 sys.path.append(os.path.join(base_dir, fdn))
                 f, n, d = imp.find_module("service")
                 module = imp.load_module("service", f, n, d)
                 cls.service[module.NAME] = module.FACTORY
                 sys.path.remove(os.path.join(base_dir, fdn))
         except Exception as e:
             L.warning('error: could not search "service.py" file in %s : %s' % (fdn, e))
コード例 #5
0
 def get_config(cls, conf=""):
     """
         Get Config File.
         :arg string conf: config file path.
     """
     cls.config = {}
     if conf == "":
         conf = os.path.join(define.APP_SCRIPT, "config.ini")
     try:
         config = ConfigParser.ConfigParser()
         config.read(conf)
         for section in config.sections():
             for option in config.options(section):
                 cls.config["%s.%s" % (section, option)] = config.get(section, option)
     except Exception as e:
         L.warning('error: could not read config file: %s' % e)
コード例 #6
0
 def parse_testcase(self, filename, folder=define.APP_EXCEL):
     """
         Parse TestCases in the ".csv" File.
         :arg string filename: csv filename.
         :arg string folder: exists csv file. Default : bantorra/excel
     """
     self.testcase = []
     try:
         path, ext = os.path.splitext(filename)
         if ext != ".csv": pass
         else:
             with open(os.path.join(folder, filename), 'r') as f:
                 reader = csv.reader(f)
                 next(reader)
                 for r in reader: self.testcase.append(r[0])
     except Exception, e:
         L.warning('error: could not read config file: %s' % e)
         return
コード例 #7
0
 def service_check(cls, conf=""):
     serv = cls._service_parse(conf)
     for s in serv:
         if not s in cls.service:
             L.warning("error : not installed service: %s" % s)
             sys.exit(1)
コード例 #8
0
 def picture_crop(self, pic, box="", filename=""):
     try:
         return self.picture.crop_picture(pic, box, filename)
     except Exception as e:
         L.warning(e)
コード例 #9
0
 def ret_rgb(self, pic, box=""):
     try:
         return self.picture.get_rgb(pic, box)
     except Exception as e:
         L.warning(e)
コード例 #10
0
 def picture_is_pattern(self, reference, target):
     try:
         return self.picture.is_pattern(reference, target)
     except Exception as e:
         L.warning(e)
コード例 #11
0
 def stop_all(cls):
     try:
         for x in cls.service.values():
             x.shutdown()
     except Exception as e:
         L.warning(str(e))