Exemple #1
0

if __name__ == '__main__':
    logging.config.fileConfig(
        os.path.join(PROJECT_DIR, 'google_api_driver/logging.conf'),
        defaults={'logfilename': MAIN_LOG_PATH})
    logger.info('google api engine started')

    # Run the program
    # Try to obtain the name of directory in GoogleDrive to upload the file:
    parser = SettingsParser()
    dir_id = parser.get('dir_id')
    if len(dir_id) == 0:
        # if there is no upload directory_id - try to create one
        # and save it to settings.dir_id
        dir_id = dir_utilities.create_remote_folder()
        parser.set('dir_id', dir_id)
        # settings_changer.change_field("dir_id", dir_id)
    # TODO: 1) Investigate why it doesn't upload files in directory
    # TODO: with dir_id for the 1st time
    # TODO: 2) Investigate why everything is OK when dir_id is not empty in
    # TODO: settings but it doesn't exist in Google Drive
    engine = google_api_driver.GoogleDrive(parent_id=dir_id)
    files_to_upload = engine.get_files_to_upload()

    # Run the function to upload file
    for f in files_to_upload:
        engine.upload_file(f)

    logger.info('google api engine finished')
 def test_folder_id(self):
     parent_id = create_remote_folder(folder_name="BackupMe")
     self.assertIsNotNone(parent_id)