Esempio n. 1
0
    def modify_job(self,
                   api_token,
                   job_id,
                   fidelity=None,
                   turnaround_hours=None,
                   priority=None):
        """
        Modify parameters of an already existing job. The job must be in Authorization state.
        :param api_token: The API token used for this session
        :type api_token: basestring
        :param job_id: The ID of the job which is being modified
        :type job_id: basestring
        :param fidelity: The desired fidelity of the transcription
        :type fidelity: Fidelity|basestring|None
        :param turnaround_hours: The number of hours after which the job is returned
        :type turnaround_hours: int|None
        :param priority: The desired priority of the transcription
        :type priority: Priority|basestring|None
        """
        query_dict = self.__init_job_req_dict(api_token, job_id)

        if fidelity:
            query_dict['transcription_fidelity'] = fidelity
        if priority:
            query_dict['priority'] = priority
        if turnaround_hours:
            query_dict['turnaround_hours'] = turnaround_hours

        WebUtils.http_request(self.base_url, self.MODIFY_JOB_PATH, 'POST',
                              WebUtils.BASIC_TIMEOUT, query_dict)
Esempio n. 2
0
 def logout(self, api_token):
     """
     :type api_token: basestring
     """
     query_dict = self.__init_access_req_dict(api_token)
     # Nothing returned
     WebUtils.http_request(self.base_url, self.LOGOUT_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
Esempio n. 3
0
 def authorize_job(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     # Nothing returned
     WebUtils.http_request(self.base_url, self.AUTHORIZE_JOB_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
Esempio n. 4
0
 def logout(self, api_token):
     """
     :type api_token: basestring
     """
     query_dict = self.__init_access_req_dict(api_token)
     # Nothing returned
     WebUtils.http_request(self.base_url, self.LOGOUT_PATH, 'GET',
                           WebUtils.BASIC_TIMEOUT, query_dict)
Esempio n. 5
0
 def authorize_job(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     # Nothing returned
     WebUtils.http_request(self.base_url, self.AUTHORIZE_JOB_PATH, 'GET',
                           WebUtils.BASIC_TIMEOUT, query_dict)
Esempio n. 6
0
 def update_password(self, api_token, new_password, sub_account=None):
     self.__assert_argument(new_password, 'New Password')
     query_dict = self.__init_access_req_dict(api_token)
     query_dict['new_password'] = new_password
     if sub_account:
         # username parameter named sub_account for clarity
         query_dict['username'] = sub_account
     # Nothing returned
     WebUtils.http_request(self.base_url, self.UPDATE_PASSWORD_PATH, 'POST', WebUtils.BASIC_TIMEOUT, None, None, urlencode(query_dict))
Esempio n. 7
0
 def remove_api_key(self, api_token, api_securekey):
     """
     :type api_token: basestring
     :type api_securekey: basestring
     """
     self.__assert_argument(api_securekey, 'API Secure Key')
     query_dict = self.__init_access_req_dict(api_token)
     query_dict['api_securekey'] = api_securekey
     # Nothing returned
     WebUtils.http_request(self.base_url, self.REMOVE_API_KEY_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
Esempio n. 8
0
 def remove_api_key(self, api_token, api_securekey):
     """
     :type api_token: basestring
     :type api_securekey: basestring
     """
     self.__assert_argument(api_securekey, 'API Secure Key')
     query_dict = self.__init_access_req_dict(api_token)
     query_dict['api_securekey'] = api_securekey
     # Nothing returned
     WebUtils.http_request(self.base_url, self.REMOVE_API_KEY_PATH, 'GET',
                           WebUtils.BASIC_TIMEOUT, query_dict)
Esempio n. 9
0
 def update_password(self, api_token, new_password, sub_account=None):
     """
     :type api_token: basestring
     :type new_password: basestring
     :type sub_account: basestring|None
     """
     self.__assert_argument(new_password, 'New Password')
     query_dict = self.__init_access_req_dict(api_token)
     query_dict['new_password'] = new_password
     if sub_account:
         # username parameter named sub_account for clarity
         query_dict['username'] = sub_account
     # Nothing returned
     WebUtils.http_request(self.base_url, self.UPDATE_PASSWORD_PATH, 'POST',
                           WebUtils.BASIC_TIMEOUT, None, None,
                           urlencode(query_dict))
Esempio n. 10
0
 def aggregate_statistics(self,
                          api_token,
                          metrics=None,
                          group_by=None,
                          start_date=None,
                          end_date=None,
                          sub_account=None):
     """
     :type api_token: basestring
     :type metrics: list|None
     :type group_by: basestring|None
     :type start_date: date|None
     :type end_date: date|None
     :type sub_account: basestring|None
     :rtype: dict
     """
     query_dict = self.__init_access_req_dict(api_token)
     if metrics:
         query_dict['metrics'] = json.dumps(metrics)
     if group_by:
         query_dict['group_by'] = group_by
     if start_date:
         query_dict['start_date'] = start_date.isoformat()
     if end_date:
         query_dict['end_date'] = end_date.isoformat()
     if sub_account:
         # account_id parameter named sub_account for clarity
         query_dict['account_id'] = sub_account
     response = WebUtils.get_json(self.base_url,
                                  self.AGGREGATE_STATISTICS_PATH, 'GET',
                                  WebUtils.BASIC_TIMEOUT, query_dict)
     return response
Esempio n. 11
0
    def create_job(self,
                   api_token,
                   job_name=None,
                   language=Language.ENGLISH,
                   external_id=None,
                   sub_account=None):
        """
        :type api_token: basestring
        :type job_name: basestring
        :type language: basestring|Language
        :type external_id: basestring
        :type sub_account: basestring
        :rtype: dict
        """
        query_dict = self.__init_access_req_dict(api_token)

        if job_name:
            query_dict['job_name'] = job_name
        if language:
            query_dict['language'] = language
        if external_id:
            query_dict['external_id'] = external_id
        if sub_account:
            # username parameter named sub_account for clarity
            query_dict['username'] = sub_account

        response = WebUtils.get_json(self.base_url, self.CREATE_JOB_PATH,
                                     'GET', WebUtils.BASIC_TIMEOUT, query_dict)
        # Return a hash with JobId and TaskId
        return response
Esempio n. 12
0
 def __send_media_url(self, api_token, job_id, media_url, path):
     self.__assert_argument(media_url, 'Media URL')
     query_dict = self.__init_job_req_dict(api_token, job_id)
     query_dict['media_url'] = media_url
     response = WebUtils.get_json(self.base_url, path, 'GET',
                                  WebUtils.BASIC_TIMEOUT, query_dict)
     return response['TaskId']
Esempio n. 13
0
    def perform_transcription(self,
                              api_token,
                              job_id,
                              fidelity,
                              priority=None,
                              callback_url=None,
                              turnaround_hours=None,
                              target_language=None,
                              options=None):
        self.__assert_argument(fidelity, 'Fidelity')
        query_dict = self.__init_job_req_dict(api_token, job_id)
        query_dict['transcription_fidelity'] = fidelity
        if priority:
            query_dict['priority'] = priority
        if callback_url:
            query_dict['callback_url'] = callback_url
        if turnaround_hours:
            query_dict['turnaround_hours'] = turnaround_hours
        if target_language:
            query_dict['target_language'] = target_language
        if options:
            query_dict['options'] = json.dumps(options.get_dict())

        response = WebUtils.get_json(self.base_url, self.PERFORM_TRANSCRIPTION, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
        return response['TaskId']
Esempio n. 14
0
 def add_media_to_job_file(self, api_token, job_id, media_file):
     self.__assert_argument(media_file, 'Media File')
     query_dict = self.__init_job_req_dict(api_token, job_id)
     file_size = fstat(media_file.fileno()).st_size
     response = WebUtils.get_json(self.base_url, self.ADD_MEDIA_TO_JOB_PATH, 'POST', WebUtils.UPLOAD_TIMEOUT,
                                  query_dict, {'Content-Type': 'video/mp4', 'Content-Length': file_size}, media_file)
     return response['TaskId']
Esempio n. 15
0
    def get_caption(self,
                    api_token,
                    job_id,
                    caption_format,
                    caption_options=None):
        """
        :type api_token: basestring
        :type job_id: basestring
        :type caption_format: CaptionFormat|basestring
        :type caption_options: TranscriptOptions|None
        :rtype: basestring
        """
        self.__assert_argument(caption_format, 'Caption Format')
        query_dict = self.__init_job_req_dict(api_token, job_id)
        query_dict['caption_format'] = caption_format
        if caption_options:
            query_dict.update(caption_options.get_dict())

        response = WebUtils.http_request(self.base_url, self.GET_CAPTION_PATH,
                                         'GET', WebUtils.DOWNLOAD_TIMEOUT,
                                         query_dict)
        if caption_options and caption_options.build_url:  # If build_url is true
            return JSONDecoder().decode(response)[
                'CaptionUrl']  # Return Caption URL
        else:
            return response  # Else return raw caption text
Esempio n. 16
0
    def get_element_list(self, api_token, job_id, elementlist_version=None):
        query_dict = self.__init_job_req_dict(api_token, job_id)
        if elementlist_version:
            query_dict['elementlist_version'] = elementlist_version

        response = WebUtils.get_json(self.base_url, self.GET_ELEMENT_LIST_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
        return response
Esempio n. 17
0
 def generate_api_key(self, api_token, username, force_new=False):
     self.__assert_argument(username, 'Username')
     query_dict = self.__init_access_req_dict(api_token)
     query_dict['account_id'] = username
     query_dict['force_new'] = force_new
     response = WebUtils.get_json(self.base_url, self.GENERATE_API_KEY_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response['ApiKey']
Esempio n. 18
0
    def login(self, username, password=None, api_securekey=None, use_headers=False):
        """
        :type username: basestring
        :type password: basestring|None
        :type api_securekey: basestring|None
        :type use_headers: bool
        :rtype: basestring
        """
        self.__assert_argument(username, 'Username')
        # Password or API Secure Key must be supplied but not both
        if password is None and api_securekey is None:
            raise ValueError('Password or API Secure Key must be supplied for login.')

        query_dict = self.__init_version_dict()
        headers = dict()

        if use_headers:
            headers['x-auth-user'] = username
            if password:
                headers['x-auth-password'] = password
            if api_securekey:
                headers['x-auth-securekey'] = api_securekey
        else:
            query_dict['username'] = username
            if password:
                query_dict['password'] = password
            if api_securekey:
                query_dict['securekey'] = api_securekey

        response = WebUtils.get_json(self.base_url, self.LOGIN_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict, headers)
        return response['ApiToken']
Esempio n. 19
0
 def get_list_of_element_lists(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     :rtype: list
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     response = WebUtils.get_json(self.base_url, self.GET_LIST_OF_ELEMENT_LISTS_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response
Esempio n. 20
0
 def get_job_info(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     :rtype: dict
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     response = WebUtils.get_json(self.base_url, self.GET_JOB_INFO_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response
Esempio n. 21
0
 def get_media(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     :rtype: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     response = WebUtils.get_json(self.base_url, self.GET_MEDIA_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response['MediaUrl']
Esempio n. 22
0
 def delete_job(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     :rtype: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     response = WebUtils.get_json(self.base_url, self.DELETE_JOB_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response['TaskId']
Esempio n. 23
0
 def delete_job(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     :rtype: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     response = WebUtils.get_json(self.base_url, self.DELETE_JOB_PATH,
                                  'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response['TaskId']
Esempio n. 24
0
 def get_media(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     :rtype: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     response = WebUtils.get_json(self.base_url, self.GET_MEDIA_PATH, 'GET',
                                  WebUtils.BASIC_TIMEOUT, query_dict)
     return response['MediaUrl']
Esempio n. 25
0
 def get_job_info(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     :rtype: dict
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     response = WebUtils.get_json(self.base_url, self.GET_JOB_INFO_PATH,
                                  'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response
Esempio n. 26
0
 def get_job_list(self, api_token, options=None):
     """
     :type api_token: basestring
     :type options: JobListOptions|None
     :rtype: list
     """
     query_dict = self.__init_access_req_dict(api_token)
     if options:
         query_dict.update(options.get_dict())
     response = WebUtils.get_json(self.base_url, self.GET_JOB_LIST_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response
Esempio n. 27
0
 def get_list_of_element_lists(self, api_token, job_id):
     """
     :type api_token: basestring
     :type job_id: basestring
     :rtype: list
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     response = WebUtils.get_json(self.base_url,
                                  self.GET_LIST_OF_ELEMENT_LISTS_PATH,
                                  'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response
Esempio n. 28
0
 def get_job_list(self, api_token, options=None):
     """
     :type api_token: basestring
     :type options: JobListOptions|None
     :rtype: list
     """
     query_dict = self.__init_access_req_dict(api_token)
     if options:
         query_dict.update(options.get_dict())
     response = WebUtils.get_json(self.base_url, self.GET_JOB_LIST_PATH,
                                  'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response
Esempio n. 29
0
    def get_caption(self, api_token, job_id, caption_format, caption_options=None):
        self.__assert_argument(caption_format, 'Caption Format')
        query_dict = self.__init_job_req_dict(api_token, job_id)
        query_dict['caption_format'] = caption_format
        if caption_options:
            query_dict.update(caption_options.get_dict())

        response = WebUtils.http_request(self.base_url, self.GET_CAPTION_PATH, 'GET', WebUtils.DOWNLOAD_TIMEOUT, query_dict)
        if caption_options and caption_options.build_url:  # If build_url is true
            return JSONDecoder().decode(response)['CaptionUrl']  # Return Caption URL
        else:
            return response  # Else return raw caption text
Esempio n. 30
0
 def get_transcript(self, api_token, job_id, transcript_options=None):
     """
     :type api_token: basestring
     :type job_id: basestring
     :type transcript_options: TranscriptOptions|None
     :rtype: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     if transcript_options:
         query_dict.update(transcript_options.get_dict())
     # Returns raw transcript text
     return WebUtils.http_request(self.base_url, self.GET_TRANSCRIPT_PATH, 'GET', WebUtils.DOWNLOAD_TIMEOUT, query_dict)
Esempio n. 31
0
    def get_element_list(self, api_token, job_id, elementlist_version=None):
        """
        :type api_token: basestring
        :type job_id: basestring
        :type elementlist_version: datetime|basestring
        :rtype: dict
        """
        query_dict = self.__init_job_req_dict(api_token, job_id)
        if elementlist_version:
            query_dict['elementlist_version'] = elementlist_version

        response = WebUtils.get_json(self.base_url, self.GET_ELEMENT_LIST_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
        return response
Esempio n. 32
0
 def generate_api_key(self, api_token, sub_account=None, force_new=False):
     """
     :type api_token: basestring
     :type sub_account: basestring|None
     :type force_new: bool
     :rtype: basestring
     """
     query_dict = self.__init_access_req_dict(api_token)
     if sub_account:
         # account_id parameter named sub_account for clarity
         query_dict['account_id'] = sub_account
     query_dict['force_new'] = force_new
     response = WebUtils.get_json(self.base_url, self.GENERATE_API_KEY_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response['ApiKey']
Esempio n. 33
0
 def get_transcript(self, api_token, job_id, transcript_options=None):
     """
     :type api_token: basestring
     :type job_id: basestring
     :type transcript_options: TranscriptOptions|None
     :rtype: basestring
     """
     query_dict = self.__init_job_req_dict(api_token, job_id)
     if transcript_options:
         query_dict.update(transcript_options.get_dict())
     # Returns raw transcript text
     return WebUtils.http_request(self.base_url, self.GET_TRANSCRIPT_PATH,
                                  'GET', WebUtils.DOWNLOAD_TIMEOUT,
                                  query_dict)
Esempio n. 34
0
    def get_element_list(self, api_token, job_id, elementlist_version=None):
        """
        :type api_token: basestring
        :type job_id: basestring
        :type elementlist_version: datetime|basestring
        :rtype: dict
        """
        query_dict = self.__init_job_req_dict(api_token, job_id)
        if elementlist_version:
            query_dict['elementlist_version'] = elementlist_version

        response = WebUtils.get_json(self.base_url, self.GET_ELEMENT_LIST_PATH,
                                     'GET', WebUtils.BASIC_TIMEOUT, query_dict)
        return response
Esempio n. 35
0
    def modify_job(self, api_token, job_id, fidelity=None, turnaround_hours=None, priority=None):
        """
        Modify parameters of an already existing job. The job must be in Authorization state.
        :param api_token: The API token used for this session
        :type api_token: basestring
        :param job_id: The ID of the job which is being modified
        :type job_id: basestring
        :param fidelity: The desired fidelity of the transcription
        :type fidelity: Fidelity|basestring|None
        :param turnaround_hours: The number of hours after which the job is returned
        :type turnaround_hours: int|None
        :param priority: The desired priority of the transcription
        :type priority: Priority|basestring|None
        """
        query_dict = self.__init_job_req_dict(api_token, job_id)

        if fidelity:
            query_dict['transcription_fidelity'] = fidelity
        if priority:
            query_dict['priority'] = priority
        if turnaround_hours:
            query_dict['turnaround_hours'] = turnaround_hours

        WebUtils.http_request(self.base_url, self.MODIFY_JOB_PATH, 'POST', WebUtils.BASIC_TIMEOUT, query_dict)
Esempio n. 36
0
 def generate_api_key(self, api_token, sub_account=None, force_new=False):
     """
     :type api_token: basestring
     :type sub_account: basestring|None
     :type force_new: bool
     :rtype: basestring
     """
     query_dict = self.__init_access_req_dict(api_token)
     if sub_account:
         # account_id parameter named sub_account for clarity
         query_dict['account_id'] = sub_account
     query_dict['force_new'] = force_new
     response = WebUtils.get_json(self.base_url, self.GENERATE_API_KEY_PATH,
                                  'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response['ApiKey']
Esempio n. 37
0
    def create_job(self, api_token, job_name=None, language=Language.ENGLISH, external_id=None, sub_account=None):
        query_dict = self.__init_access_req_dict(api_token)

        if job_name:
            query_dict['job_name'] = job_name
        if language:
            query_dict['language'] = language
        if external_id:
            query_dict['external_id'] = external_id
        if sub_account:
            # username parameter named sub_account for clarity
            query_dict['username'] = sub_account

        response = WebUtils.get_json(self.base_url, self.CREATE_JOB_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
        # Return a hash with JobId and TaskId
        return response
Esempio n. 38
0
 def add_media_to_job_file(self, api_token, job_id, media_file):
     """
     :type api_token: basestring
     :type job_id: basestring
     :type media_file: file
     :rtype: basestring
     """
     self.__assert_argument(media_file, 'Media File')
     query_dict = self.__init_job_req_dict(api_token, job_id)
     file_size = fstat(media_file.fileno()).st_size
     response = WebUtils.get_json(self.base_url, self.ADD_MEDIA_TO_JOB_PATH,
                                  'POST', WebUtils.UPLOAD_TIMEOUT,
                                  query_dict, {
                                      'Content-Type': 'video/mp4',
                                      'Content-Length': file_size
                                  }, media_file)
     return response['TaskId']
Esempio n. 39
0
    def login(self,
              username,
              password=None,
              api_securekey=None,
              use_headers=False):
        """
        :type username: basestring
        :type password: basestring|None
        :type api_securekey: basestring|None
        :type use_headers: bool
        :rtype: basestring
        """
        self.__assert_argument(username, 'Username')
        # Password or API Secure Key must be supplied but not both
        if password is None and api_securekey is None:
            raise ValueError(
                'Password or API Secure Key must be supplied for login.')

        query_dict = self.__init_version_dict()
        headers = dict()

        if use_headers:
            headers['x-auth-user'] = username
            if password:
                headers['x-auth-password'] = password
            if api_securekey:
                headers['x-auth-securekey'] = api_securekey
        else:
            query_dict['username'] = username
            if password:
                query_dict['password'] = password
            if api_securekey:
                query_dict['securekey'] = api_securekey

        response = WebUtils.get_json(self.base_url, self.LOGIN_PATH, 'GET',
                                     WebUtils.BASIC_TIMEOUT, query_dict,
                                     headers)
        return response['ApiToken']
Esempio n. 40
0
    def perform_transcription(self,
                              api_token,
                              job_id,
                              fidelity,
                              priority=None,
                              callback_url=None,
                              turnaround_hours=None,
                              target_language=None,
                              options=None):
        """
        :type api_token: basestring
        :type job_id: basestring
        :type fidelity: Fidelity|basestring
        :type priority: Priority|basestring|None
        :type callback_url: basestring|None
        :type turnaround_hours: int|None
        :type target_language: Language|basestring|None
        :type options: PerformTranscriptionOptions|None
        :rtype: basestring
        """
        self.__assert_argument(fidelity, 'Fidelity')
        query_dict = self.__init_job_req_dict(api_token, job_id)
        query_dict['transcription_fidelity'] = fidelity
        if priority:
            query_dict['priority'] = priority
        if callback_url:
            query_dict['callback_url'] = callback_url
        if turnaround_hours:
            query_dict['turnaround_hours'] = turnaround_hours
        if target_language:
            query_dict['target_language'] = target_language
        if options:
            query_dict['options'] = json.dumps(options.get_dict())

        response = WebUtils.get_json(self.base_url, self.PERFORM_TRANSCRIPTION,
                                     'GET', WebUtils.BASIC_TIMEOUT, query_dict)
        return response['TaskId']
Esempio n. 41
0
 def aggregate_statistics(self, api_token, metrics=None, group_by=None, start_date=None, end_date=None, sub_account=None):
     """
     :type api_token: basestring
     :type metrics: list|None
     :type group_by: basestring|None
     :type start_date: date|None
     :type end_date: date|None
     :type sub_account: basestring|None
     :rtype: dict
     """
     query_dict = self.__init_access_req_dict(api_token)
     if metrics:
         query_dict['metrics'] = json.dumps(metrics)
     if group_by:
         query_dict['group_by'] = group_by
     if start_date:
         query_dict['start_date'] = start_date.isoformat()
     if end_date:
         query_dict['end_date'] = end_date.isoformat()
     if sub_account:
         # account_id parameter named sub_account for clarity
         query_dict['account_id'] = sub_account
     response = WebUtils.get_json(self.base_url, self.AGGREGATE_STATISTICS_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response
Esempio n. 42
0
 def get_job_list(self, api_token, options=None):
     query_dict = self.__init_access_req_dict(api_token)
     if options:
         query_dict.update(options.get_dict())
     response = WebUtils.get_json(self.base_url, self.GET_JOB_LIST_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response
Esempio n. 43
0
 def __send_media_url(self, api_token, job_id, media_url, path):
     self.__assert_argument(media_url, 'Media URL')
     query_dict = self.__init_job_req_dict(api_token, job_id)
     query_dict['media_url'] = media_url
     response = WebUtils.get_json(self.base_url, path, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response['TaskId']
Esempio n. 44
0
 def get_job_info(self, api_token, job_id):
     query_dict = self.__init_job_req_dict(api_token, job_id)
     response = WebUtils.get_json(self.base_url, self.GET_JOB_INFO_PATH, 'GET', WebUtils.BASIC_TIMEOUT, query_dict)
     return response
Esempio n. 45
0
    url = ''

    for figure_dict in figure_content:
        title = figure_dict[web_utils.TITLE_FIELD]
        abstract = figure_dict[web_utils.ABSTRACT_FIELD]
        url = sei.get_pdf_url(figure_dict[web_utils.PAPER_FIELD])

    tore_turn = {'title': title, 'abstract': abstract, 'url': url}
    response = Response(response=json.dumps(tore_turn), status=200, mimetype='application/json')

    return response


if __name__ == '__main__':

    web_utils = WebUtils('../fig.explorer.config')

    fields_menu, field_names, initial_field_weights, model_names = web_utils.build_settings_menu()
    collection_menu, collection_names, query_examples_1, query_examples_2 = web_utils.build_collection_menu()
    top_menu = web_utils.build_top_menu()

    web_port_number = int(web_utils.configurations_dict.get(web_utils.WEB_APP_PORT, [('5000',)])[0][0])
    lucene_port_number = int(web_utils.configurations_dict.get(web_utils.LUCENE_PORT_NUM, [('25000',)])[0][0])
    host_name = web_utils.configurations_dict.get(web_utils.WEB_APP_HOST, [('0.0.0.0',)])[0][0]
    default_server_url = 'http://' + web_utils.configurations_dict.get(web_utils.WEB_APP_HOST, [('0.0.0.0',)])[0][0]
    default_server_url += ':' + web_utils.configurations_dict.get(web_utils.WEB_APP_PORT, [('5000',)])[0][0] + '/'
    server_url = web_utils.configurations_dict.get(web_utils.APP_URL, [(default_server_url,)])[0][0]

    server = JavaGateway(gateway_parameters=GatewayParameters(port=lucene_port_number))
    sei = SearchEngineInterface(server, web_utils)
    ml_server = MLServer(web_utils, sei)