Esempio n. 1
0
 def call_download_api(self, api: API, db_object: File) -> Tuple[str, str]:
     '''
     Override DownloadJob.
     '''
     sdk_object = SdkSubmission(uuid=db_object.uuid)
     sdk_object.source_uuid = db_object.source.uuid
     sdk_object.filename = db_object.filename
     return api.download_submission(sdk_object,
                                    timeout=self._get_realistic_timeout(db_object.size))
Esempio n. 2
0
def get_all_submissions(token: str) -> List[Submission]:
    """
    Returns a list of Python Submission objects
    """
    result = get_all_submissions_json(token)
    result = json.loads(result)
    if "sdproxyerror" in result:
        raise Exception(result["sdproxyerror"])
    return [Submission(**data) for data in result]
Esempio n. 3
0
def make_remote_submission(source_uuid):
    """
    Utility function for generating sdclientapi Submission instances to act
    upon in the following unit tests. The passed in source_uuid is used to
    generate a valid URL.
    """
    source_url = '/api/v1/sources/{}'.format(source_uuid)
    return Submission(download_url='test',
                      filename='test',
                      is_read=False,
                      size=123,
                      source_url=source_url,
                      submission_url='test',
                      uuid=str(uuid.uuid4()))
Esempio n. 4
0
def make_remote_message(source_uuid, file_counter=1):
    """
    Utility function for generating sdclientapi Message instances to act
    upon in the following unit tests. The passed in source_uuid is used to
    generate a valid URL.
    """
    source_url = "/api/v1/sources/{}".format(source_uuid)
    return Submission(
        download_url="test",
        filename="{}-submission.msg.gpg".format(file_counter),
        is_read=False,
        size=123,
        source_url=source_url,
        submission_url="test",
        uuid=str(uuid.uuid4()),
    )
Esempio n. 5
0
def get_submission(token: str, uuid: str,
                   source_uuid: str) -> List[Submission]:
    """
    Returns a Submission object.
    
    :param token: token string
    :param uuid: submission uuid string
    :param source_uuid: source uuid string
    
    :returns: Submission object
    """
    result = get_submission_json(token, uuid, source_uuid)
    result = json.loads(result)
    if "sdproxyerror" in result:
        raise Exception(result["sdproxyerror"])
    return Submission(**result)