Skip to content

Commit 02abf6f

Browse files
committed
.
1 parent 18f9ca9 commit 02abf6f

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

examples/client/upload_bdio.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python
2+
3+
'''
4+
Created on Friday, January 13th, 2023
5+
@author: kumykov
6+
7+
Copyright (C) 2021 Synopsys, Inc.
8+
http://www.blackducksoftware.com/
9+
10+
Licensed to the Apache Software Foundation (ASF) under one
11+
or more contributor license agreements. See the NOTICE file
12+
distributed with this work for additional information
13+
regarding copyright ownership. The ASF licenses this file
14+
to you under the Apache License, Version 2.0 (the
15+
"License"); you may not use this file except in compliance
16+
with the License. You may obtain a copy of the License at
17+
18+
http://www.apache.org/licenses/LICENSE-2.0
19+
20+
Unless required by applicable law or agreed to in writing,
21+
software distributed under the License is distributed on an
22+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23+
KIND, either express or implied. See the License for the
24+
specific language governing permissions and limitations
25+
under the License.
26+
27+
usage: upload_bdio [-h] -u BASE_URL -t TOKEN_FILE [-nv] filename
28+
29+
Uploads BDIO file to a Blackduck server
30+
31+
positional arguments:
32+
filename BDIO file to upload
33+
34+
optional arguments:
35+
-h, --help show this help message and exit
36+
-u BASE_URL, --base-url BASE_URL
37+
Hub server URL e.g. https://your.blackduck.url
38+
-t TOKEN_FILE, --token-file TOKEN_FILE
39+
File containing access token
40+
-nv, --no-verify Disable TLS certificate verification
41+
42+
Blackduck examples collection
43+
44+
'''
45+
46+
47+
import sys
48+
import argparse
49+
50+
from blackduck import Client
51+
52+
def main():
53+
args = parse_command_args()
54+
with open(args.token_file, 'r') as tf:
55+
access_token = tf.readline().strip()
56+
global bd
57+
bd = Client(base_url=args.base_url, token=access_token, verify=args.no_verify, timeout=60.0, retries=4)
58+
print (bd.list_resources())
59+
60+
def parse_command_args():
61+
parser = argparse.ArgumentParser(prog = "upload_bdio", description="Uploads BDIO file to a Blackduck server", epilog="Blackduck examples collection")
62+
parser.add_argument("filename", help="BDIO file to upload")
63+
parser.add_argument("-u", "--base-url", required=True, help="Hub server URL e.g. https://your.blackduck.url")
64+
parser.add_argument("-t", "--token-file", required=True, help="File containing access token")
65+
parser.add_argument("-nv", "--no-verify", action='store_false', help="Disable TLS certificate verification")
66+
return parser.parse_args()
67+
68+
69+
70+
if __name__ == "__main__":
71+
sys.exit(main())

0 commit comments

Comments
 (0)