Skip to content

Commit

Permalink
Merge pull request #30 from mariobuikhuizen/client-features
Browse files Browse the repository at this point in the history
Client features
  • Loading branch information
mariobuikhuizen authored Jul 20, 2020
2 parents 785df54 + 6e375a2 commit c756dde
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion quetz_client/quetz_client/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (0, 0, 1)
version_info = (0, 0, 2)
__version__ = '.'.join(map(str, version_info))
47 changes: 37 additions & 10 deletions quetz_client/quetz_client/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ def main():
description="Uploads package to Quetz."
)

parser.add_argument(
"--dry-run",
action='store_true',
help="Print what would happen, without uploading the package(s)")

parser.add_argument(
"--verify",
action='store_true',
help="Verify package(s) with conda-verify")

parser.add_argument(
"--verify-ignore",
type=str,
Expand All @@ -28,7 +38,7 @@ def main():
)

parser.add_argument("channel_url")
parser.add_argument("packages", nargs='+')
parser.add_argument("packages", nargs='+', help="package(s) or build root")
args = parser.parse_args()

channel_url = args.channel_url
Expand All @@ -37,19 +47,36 @@ def main():
parts = parts._replace(path=f"/api{parts.path}")
channel_url = urlunparse(parts)

package_file_names = args.packages
# Find packages in directory if the single package argument is a directory
if len(package_file_names) == 1 and os.path.isdir(package_file_names[0]):
path = package_file_names.pop()
for root, dirs, files in os.walk(path):
for file in files:
if '.json.' not in file and (file.endswith('.tar.bz2') or file.endswith('.conda')):
package_file_names.append(os.path.join(root, file))

verifier = Verify()

verify_ignore = args.verify_ignore.split(',') if args.verify_ignore else None
for package in args.packages:
verifier.verify_package(path_to_package=package, checks_to_ignore=verify_ignore,
exit_on_error=True,)
if args.verify:
verify_ignore = args.verify_ignore.split(',') if args.verify_ignore else None
for package in package_file_names:
verifier.verify_package(path_to_package=package, checks_to_ignore=verify_ignore,
exit_on_error=True,)

files = [('files', open(package, 'rb')) for package in args.packages]
files = [('files', open(package, 'rb')) for package in package_file_names]

api_key = os.getenv('QUETZ_API_KEY')

response = requests.post(f'{channel_url}/files/',
files=files,
headers={'X-API-Key': api_key})
url = f'{channel_url}/files/'
if args.dry_run:
package_lines = "\n ".join(package_file_names)
print(f'QUETZ_API_KEY found: {not not api_key}\n'
f'URL: {url}\n'
f'packages:\n {package_lines} ')
else:
response = requests.post(url,
files=files,
headers={'X-API-Key': api_key})

print(response.status_code)
print(response.status_code)

0 comments on commit c756dde

Please sign in to comment.