예제 #1
0
    def prepare(self,
                config_path=None,
                user=None,
                password=None,
                exe_path=None,
                comm_password=None,
                **kwargs):
        """
        登陆客户端
        :param config_path: 登陆配置文件,跟参数登陆方式二选一
        :param user: 账号
        :param password: 明文密码
        :param exe_path: 客户端路径类似 r'C:\\htzqzyb2\\xiadan.exe', 默认 r'C:\\htzqzyb2\\xiadan.exe'
        :param comm_password: 通讯密码
        :return:
        """
        params = locals().copy()
        params.pop("self")

        if config_path is not None:
            account = helpers.file2dict(config_path)
            params["user"] = account["user"]
            params["password"] = account["password"]

        params["broker"] = self._broker

        response = self._s.post(self._api + "/prepare", json=params)
        if response.status_code >= 300:
            raise Exception(response.json()["error"])
        return response.json()
예제 #2
0
 def read_config(self, path):
     try:
         self.account_config = helpers.file2dict(path)
     except ValueError:
         log.error('配置文件格式有误,请勿使用记事本编辑,推荐使用 notepad++ 或者 sublime text')
     for v in self.account_config:
         if type(v) is int:
             log.warn('配置文件的值最好使用双引号包裹,使用字符串类型,否则可能导致不可知的问题')
예제 #3
0
 def read_config(self, path):
     try:
         self.account_config = helpers.file2dict(path)
     except ValueError:
         log.error("配置文件格式有误,请勿使用记事本编辑,推荐 sublime text")
     for value in self.account_config:
         if isinstance(value, int):
             log.warning("配置文件的值最好使用双引号包裹,使用字符串,否则可能导致不可知问题")
예제 #4
0
 def read_config(self, path):
     try:
         self.account_config = helpers.file2dict(path)
     except ValueError:
         log.error('配置文件格式有误,请勿使用记事本编辑,推荐使用 notepad++ 或者 sublime text')
     for v in self.account_config:
         if type(v) is int:
             log.warn('配置文件的值最好使用双引号包裹,使用字符串类型,否则可能导致不可知的问题')
예제 #5
0
 def prepare(self,
             config_path=None,
             user=None,
             password=None,
             exe_path=None,
             comm_password=None,
             **kwargs):
     """
     登陆客户端
     :param config_path: 登陆配置文件,跟参数登陆方式二选一
     :param user: 账号
     :param password: 明文密码
     :param exe_path: 客户端路径类似 r'C:\\htzqzyb2\\xiadan.exe', 默认 r'C:\\htzqzyb2\\xiadan.exe'
     :param comm_password: 通讯密码
     :return:
     """
     if config_path is not None:
         account = helpers.file2dict(config_path)
         user = account["user"]
         password = account["password"]
         comm_password = account.get("comm_password")
         exe_path = account.get("exe_path")
     self.login(user, password, exe_path or self._config.DEFAULT_EXE_PATH,
                comm_password, **kwargs)
예제 #6
0
 def __read_config(self):
     """读取 config"""
     self.config = helpers.file2dict(self.config_path)
     self.global_config = helpers.file2dict(self.global_config_path)
     self.config.update(self.global_config)
예제 #7
0
 def __read_config(self):
     """读取 config"""
     self.config = helpers.file2dict(self.config_path)
     self.global_config = helpers.file2dict(self.global_config_path)
     self.config.update(self.global_config)
예제 #8
0
 def read_config(self, path):
     self.account_config = helpers.file2dict(path)