How to use the pyexpander.config.ACD_CLI_PATH function in pyexpander

To help you get started, we’ve selected a few pyexpander examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github omerbenamram / py-expander / pyexpander / upload.py View on Github external
# Rename local file before upload.
        base_dir = os.path.dirname(file_path)
        new_path = os.path.join(base_dir, cloud_file)
        os.rename(file_path, new_path)
        # Sync first.
        _sync()
        # Create cloud dirs.
        logger.info('Creating directories...')
        current_dir = ''
        for directory in cloud_dir.split('/'):
            current_dir += '/{}'.format(directory)
            subprocess.run('{} mkdir "{}"'.format(config.ACD_CLI_PATH, current_dir), shell=True)
        # Upload!
        logger.info('Uploading file...')
        process = subprocess.run('{} upload -o --remove-source-files "{}" "{}"'.format(
            config.ACD_CLI_PATH, new_path, cloud_dir), shell=True)
        # Check results.
        if process.returncode != 0:
            logger.error('Bad return code ({}) for file: {}'.format(process.returncode, file_path))
        else:
            logger.info('Upload succeeded! Deleting original file...')
            # If everything went smoothly, add the file name to the original names log.
            if not is_subtitles:
                open(config.ORIGINAL_NAMES_LOG, 'a', encoding='UTF-8').write(file_path + '\n')
            # Sync again when done.
            _sync()
    else:
        logger.info('Couldn\'t guess file info. Skipping...')
github omerbenamram / py-expander / pyexpander / upload.py View on Github external
def _sync():
    """
    Perform sync action.
    """
    process = subprocess.run('{} sync'.format(config.ACD_CLI_PATH), shell=True)
    if process.returncode != 0:
        logger.error('Bad return code ({}) for sync'.format(process.returncode))
    else:
        logger.info('Sync succeeded!')