Exemplo n.º 1
0
 def __init__(self):
     # 表示当前是否正在解析module模块
     # 用途: 值为false时,对boolean_expression的解析不会将结果保存为guard
     self.moduledefbegin = False
     '''
     当parser分析到一行Command时,可能最后会解析成多个Command对象
     每个Command对象包含以下信息:name, guard, prob, action, module
     目前默认不设置Command的name,即name为空
     module在每次解析到LB时进行初始化表示当前正在生成的module
     prob在解析到prob_expr的时候进行设置,prob是一个函数对象,因为需要根据判定对象(变量)的值进行实时计算
     最重要的Command对象在解析到prob_update时进行初始化,因为从Command的构成上讲,
     一个prob + update就构成了一个Command对象。
     之所以要在BasicParser中保存module和guard对象是因为
     它们是被多个Command对象所共享的。
     '''
     self.module = None  # 当前正在解析的module对象
     self.guard = None  # 表示当前Command对象的guard属性
     self.binary_op_map = {
         '+': lambda x, y: x + y,
         '-': lambda x, y: x - y,
         '*': lambda x, y: x * y,
         '/': lambda x, y: x / y
     }
     self.func_map = {'stdcdf': pcf}
     # name : value storage structure for constants
     self.cmap = defaultdict(lambda: None)
     # name : func object storage structure for variables and formula
     self.logger = logging.getLogger("BasicParser logging")
     self.logger.addHandler(
         logging.FileHandler(LogHelper.get_logging_root() +
                             "BasicParser.log"))
     self.logger.setLevel(logging.INFO)
     self.vcf_map = defaultdict(lambda: None)
     self.vc_map = defaultdict(lambda: None)
Exemplo n.º 2
0
    def __init__(self, config_helper, log_helper: LogHelper):
        self.logger = log_helper.get_logger(self.__class__.__name__)
        config = config_helper.get_config()
        self.locations_hltv_starting_ = config[sC.FOLDER_LOCATIONS][
            sC.HLTV_STARTING]
        self.results_ = config[sC.FOLDER_LOCATIONS][sC.CONFIGS_RESULTS]
        self.score_starting_ = config[sC.FOLDER_LOCATIONS][sC.SCORE_STARTING]
        self.amxmodx_logs_ = config[sC.FOLDER_LOCATIONS][
            sC.ADDONS_AMXMODX_LOGS]
        self.logs_starting_ = config[sC.FOLDER_LOCATIONS][sC.LOGS_STARTING]
        self.cstrike_logs_ = config[sC.FOLDER_LOCATIONS][sC.CSTRIKE_LOGS]

        _old_makepasv = FTP.makepasv

        def _new_makepasv(self_):
            """
            To use passive mode for FTP

            :param self_: current reference
            :return: host and port
            """
            host, port = _old_makepasv(self_)
            host = self_.sock.getpeername()[0]
            print(host, port)
            return host, port

        FTP.makepasv = _new_makepasv
 def __init__(self, config_helper, log_helper: LogHelper):
     self.logger = log_helper.get_logger(self.__class__.__name__)
     self.config = config_helper.get_config()
     self.ComputeEngine = get_driver(Provider.GCE)
     self.gc = self.ComputeEngine(self.config[sC.PROJECT_DETAILS][sC.SERVICE_ACCOUNT_EMAIL],
                                  self.config[sC.PROJECT_DETAILS][sC.SERVICE_ACCOUNT_KEY_PATH],
                                  project=self.config[sC.PROJECT_DETAILS][sC.PROJECT_ID])
 def __init__(self, config_helper, log_helper: LogHelper):
     self.log_helper = log_helper
     self.logger = log_helper.get_logger(self.__class__.__name__)
     self.config = config_helper.get_config()
     self.files_home_ = self.config[sC.FOLDER_LOCATIONS][sC.FILES_HOME]
     self.locations_certificates_ = self.config[sC.FOLDER_LOCATIONS][
         sC.CERTIFICATES]
     self.cert_img_path_ = self.config[sC.FILE_LOCATIONS][sC.CERT_IMG_PATH]
     self.locations_font_path_ = self.config[sC.FILE_LOCATIONS][
         sC.FONT_PATH]
Exemplo n.º 5
0
 def __init__(self, config_helper, log_helper: LogHelper):
     self.logger = log_helper.get_logger(self.__class__.__name__)
     config = config_helper.get_config()
     account_key_path_ = config[sC.PROJECT_DETAILS][
         sC.SERVICE_ACCOUNT_KEY_PATH]
     self.project_id_ = config[sC.PROJECT_DETAILS][sC.PROJECT_ID]
     self.id_list_txt_ = config[sC.FILE_LOCATIONS][sC.STEAM_ID_LIST_TXT]
     self.player_details = config[sC.FILE_LOCATIONS][sC.PLAYER_DETAILS]
     self.team_details = config[sC.FILE_LOCATIONS][sC.TEAM_DETAILS]
     self.client = datastore.Client.from_service_account_json(
         account_key_path_)
 def __init__(self, config_helper, log_helper: LogHelper):
     self.logger = log_helper.get_logger(self.__class__.__name__)
     config = config_helper.get_config()
     self.ip_log_starting_ = config[sC.FOLDER_LOCATIONS][sC.IP_LOG_STARTING]
     self.hltv_starting_ = config[sC.FOLDER_LOCATIONS][sC.HLTV_STARTING]
     self.score_starting_ = config[sC.FOLDER_LOCATIONS][sC.SCORE_STARTING]
     self.logs_starting_ = config[sC.FOLDER_LOCATIONS][sC.LOGS_STARTING]
     self.steam_api_key = config[sC.PROJECT_DETAILS][sC.STEAM_API_KEY]
     self.steam_user_api_ = config[sC.PROJECT_DETAILS][sC.STEAM_USER_API]
     self.banned_users_file_ = config[sC.FILE_LOCATIONS][
         sC.BANNED_USERS_FILE]
Exemplo n.º 7
0
 def __init__(self, log_helper: LogHelper):
     self.logger = log_helper.get_logger(self.__class__.__name__)
Exemplo n.º 8
0
 def __init__(self, config_helper, log_helper: LogHelper):
     self.logger = log_helper.get_logger(self.__class__.__name__)
     config = config_helper.get_config()
     self.project_id_ = config[sC.PROJECT_DETAILS][sC.PROJECT_ID]
     self.client = datastore.Client.from_service_account_json(
         config[sC.PROJECT_DETAILS][sC.SERVICE_ACCOUNT_KEY_PATH])
Exemplo n.º 9
0
 def __init__(self, config_helper, log_helper: LogHelper):
     self.logger = log_helper.get_logger(self.__class__.__name__)
     self.config = config_helper.get_config()
     self.ac = open(self.config[sC.FILE_LOCATIONS][sC.STEAM_ID_LIST_TXT], sC.READ_PLUS_MODE)
Exemplo n.º 10
0
 def __init__(self, config_helper, log_helper: LogHelper):
     self.logger = log_helper.get_logger(self.__class__.__name__)
     config = config_helper.get_config()
     self.STATS_FILE_ = config[sC.FILE_LOCATIONS][sC.STATS_FILE]
     self.FILES_HOME_ = config[sC.FOLDER_LOCATIONS][sC.FILES_HOME]