Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update conda_mirror.py #21

Merged
merged 1 commit into from
Jan 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions conda_mirror/conda_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ def _make_arg_parser():
help='The place where packages should be mirrored to',
required=True
)
ap.add_argument(
'--temp-directory',
help='Temporary download location for the packages',
required=False,
default=tempfile.gettempdir()
)
ap.add_argument(
'--platform',
help=("The OS platform(s) to mirror. one of: {'linux-64', 'linux-32',"
Expand Down Expand Up @@ -179,8 +185,8 @@ def pdb_hook(exctype, value, traceback):
blacklist = config_dict.get('blacklist')
whitelist = config_dict.get('whitelist')

main(args.upstream_channel, args.target_directory, args.platform,
blacklist, whitelist)
main(args.upstream_channel, args.target_directory, args.temp_directory,
args.platform, blacklist, whitelist)


def _remove_package(pkg_path):
Expand Down Expand Up @@ -289,8 +295,8 @@ def _validate_packages(repodata, package_directory):
size=info.get('size'))


def main(upstream_channel, target_directory, platform, blacklist=None,
whitelist=None):
def main(upstream_channel, target_directory, temp_directory, platform,
blacklist=None, whitelist=None):
"""

Parameters
Expand All @@ -302,6 +308,10 @@ def main(upstream_channel, target_directory, platform, blacklist=None,
The path on disk to produce a local mirror of the upstream channel.
Note that this is the directory that contains the platform
subdirectories.
temp_directory : str
The path on disk to an existing and writable directory to temporarily
store the packages before moving them to the target_directory to
apply checks
platform : str
The platform that you want to mirror from
anaconda.org/<upstream_channel>
Expand Down Expand Up @@ -415,7 +425,7 @@ def main(upstream_channel, target_directory, platform, blacklist=None,
# b. validate contents of temp file
# c. move to local repo
# mirror all new packages
with tempfile.TemporaryDirectory() as download_dir:
with tempfile.TemporaryDirectory(dir=temp_directory) as download_dir:
logger.info('downloading to the tempdir %s', download_dir)
for package_name in sorted(to_mirror):
url = DOWNLOAD_URL.format(
Expand Down