Exemple #1
0
    def post_stat(self, pipeline_inst_id, stat):
        """
        Post stat to agent using json formatting
        :param pipeline_inst_id: pipeline instance identifier
        :param stat:             stat in json format
        :return:                 Json response from agent
        """
        if pipeline_inst_id is None:
            self._error("Missing pipeline instance id cannot post stat")
            return

        url = self.url_post_stat(pipeline_inst_id)
        try:
            payload = encoder(stat)
            headers = {"Content-Type": "application/json;charset=UTF-8"}
            r = requests.post(url,
                              data=payload,
                              headers=headers,
                              cookies=self._return_cookie())
            if r.ok:
                return r.json()
            else:
                self._error('Call {} with payload {} failed: text:[{}]'.format(
                    url, stat, r.text))
        except requests.exceptions.ConnectionError as e:
            self._error(e)
            raise MLOpsConnectionException(
                "Connection to MLOps agent [{}:{}] refused; {}".format(
                    self._mlops_server, self._mlops_port, e))
        except Exception as e:
            raise MLOpsException('Call ' + str(url) + ' failed with error ' +
                                 str(e))
Exemple #2
0
 def post_event(self, pipeline_inst_id, event):
     """
     Post event using protobuf format
     :param pipeline_inst_id:  pipeline instance identifier
     :param event:             ReflexEvent based on protobuf
     :return:                  Json response from agent
     """
     url = self.url_post_event(pipeline_inst_id)
     try:
         payload = encoder(event)
         headers = {"Content-Type": "application/json;charset=UTF-8"}
         r = requests.post(url,
                           data=payload,
                           headers=headers,
                           cookies=self._return_cookie())
         if r.ok:
             return r.json()
         else:
             self._error('Call {} with payload {} failed: text:[{}]'.format(
                 url, event, r.text))
     except requests.exceptions.ConnectionError as e:
         raise MLOpsConnectionException(
             "Connection to MLOps agent [{}:{}] refused; {}".format(
                 self._mlops_server, self._mlops_port, e))
     except Exception as e:
         raise MLOpsException('Call ' + str(url) + ' failed with error: ' +
                              str(e))
Exemple #3
0
 def POST(self, url, args=None):
     code = 500
     body = ""
     if args != None:
         args = encoder(args)
     header, cnetloc, port = self.master_parser(parser(url), 'POST', args)
     code, body = self.master_servicer(cnetloc, port, header)
     #print('our result: ' + str(code)+str(body))
     self.close()
     return HTTPResponse(code, body)
Exemple #4
0
def open_app(service):
    installed = False
    try:
        os.system("start " + service)
        installed = True

    except Exception as e:
        print(e.__str__())
        os.system(service)
        installed = True

    finally:
        if not installed:
            print("Unable to process command, try using different keywords")
        confirm = input(
            f"Type yes to show web results for {command} or press any other key to continue"
        )
        if confirm or confirm in ["yes", "yeah", "yup"]:
            os.system("start www.google.com/search?q=" + encoder(service))
 def get_query_url(self):
     querystring = encoder(self._qdict)
     return "{base_url}/?{querystring}".format(base_url=self.BASE_URL,
                                               querystring=querystring)