예제 #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:
     """
     if config_path is not None:
         account = 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
     )
예제 #2
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 = 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()
예제 #3
0
 def read_config(self, path):
     try:
         self.account_config = file2dict(path)
     except ValueError:
         logger.error("配置文件格式有误,请勿使用记事本编辑,推荐 sublime text")
     for value in self.account_config:
         if isinstance(value, int):
             logger.warning("配置文件的值最好使用双引号包裹,使用字符串,否则可能导致不可知问题")
예제 #4
0
 def prepare(
     self,
     config_path=None,
     user=None,
     password=None,
     token=None,
     address=None,
     timeout=5,
 ):
     if config_path is not None:
         account = file2dict(config_path)
         token = account['token']
         #user = account['user']
         #password = account['password']
         address = account['address']
         timeout = account['timeout']
     self.token = token
     self.user = user
     self.password = password
     self.address = address
     self.timeout = timeout
     return self._api_get('prepare')
예제 #5
0
 def __read_config(self):
     """读取 config"""
     self.config = file2dict(self.config_path)
     self.global_config = file2dict(self.global_config_path)
     self.config.update(self.global_config)