Example #1
0
    def get_list(self):
        self.full_lists_path = create_resource_folder(self.library_path +
                                                      "/full_lists")
        self.lists_path = create_resource_folder(self.library_path + "/lists")

        full_list_path = download_file(self.list_url, self.full_lists_path)
        self.trim_list(full_list_path)
Example #2
0
  def download_team_crest(self, team):
    link = team.crest_url
    path = team.crest_path

    if not os.path.exists(path):
      path = download_file(link, path)

    return path
Example #3
0
    def get_all_sentences_files(self):
        sentences_compressed = download_file(self.sentences_url,
                                             self.sentences_path,
                                             self.download)

        sentence_links_compressed = download_file(self.sentence_links_url,
                                                  self.sentences_path,
                                                  self.download)

        sentences_with_audio_compressed = download_file(
            self.sentences_with_audio_url, self.sentences_path, self.download)

        sentences_file_path = decompress_file(sentences_compressed,
                                              self.download)

        sentence_links_path = decompress_file(sentence_links_compressed,
                                              self.download)

        sentences_with_audio_path = decompress_file(
            sentences_with_audio_compressed, self.download)

        return sentences_file_path, sentence_links_path, sentences_with_audio_path
Example #4
0
    def retrieve(self, request, *args, **kwargs):
        re_auth('source')
        re_auth('target')
        auth_json = ModifyAuthJson()

        datastore = DatastoreMigration()
        source_datastores = datastore.get_existing_datastores(
            base_url=auth_json.get_base_url('source'),
            headers=auth_json.get_xsrf_header('source'),
            cookies=auth_json.get_cookies('source'))

        target_datastores = datastore.get_existing_datastores(
            base_url=auth_json.get_base_url('target'),
            headers=auth_json.get_xsrf_header('target'),
            cookies=auth_json.get_cookies('target'))

        for source_datastore in source_datastores:
            re_auth('source')
            re_auth('target')
            datastore_attributes = datastore.get_datastore_attributes(
                base_url=auth_json.get_base_url('source'),
                headers=auth_json.get_xsrf_header('source'),
                cookies=auth_json.get_cookies('source'),
                dsm_id=source_datastore['id'])

            datastore.generate_datastore_dump_report(
                base_url=auth_json.get_base_url('source'),
                headers=auth_json.get_xsrf_header('source'),
                cookies=auth_json.get_cookies('source'),
                dsm_id=source_datastore['id'],
                ds_attributes=[
                    ds_attribute['key']
                    for ds_attribute in datastore_attributes
                ])

            download_url = datastore.get_datastore_dump_download_url(
                base_url=auth_json.get_base_url('source'),
                headers=auth_json.get_xsrf_header('source'),
                cookies=auth_json.get_cookies('source'),
                dsm_id=source_datastore['id'])

            if download_url:
                csv_path = download_file(download_url)
                excel_path = datastore.convert_dump_to_excel(
                    csv_path, datastore_attributes)
                remove(csv_path)
                datastore.upload_excel(
                    base_url=auth_json.get_base_url('target'),
                    headers=auth_json.get_xsrf_header('target'),
                    cookies=auth_json.get_cookies('target'),
                    dsm_id=[
                        target_datastore['id']
                        for target_datastore in target_datastores
                        if target_datastore['code'] == source_datastore['code']
                    ][0],
                    file_path=excel_path,
                    type='add')
                datastore.upload_excel(
                    base_url=auth_json.get_base_url('target'),
                    headers=auth_json.get_xsrf_header('target'),
                    cookies=auth_json.get_cookies('target'),
                    dsm_id=[
                        target_datastore['id']
                        for target_datastore in target_datastores
                        if target_datastore['code'] == source_datastore['code']
                    ][0],
                    file_path=excel_path,
                    type='update')
                remove(excel_path)

        return Response(
            {
                'success': True,
                'message': 'datastore values migrated successfully',
            },
            status=status.HTTP_200_OK)