def dxf_obj(request): # pylint: disable=redefined-outer-name regver, from_base, auth, do_token, tlsverify = _setup_fixture(request) if from_base: base = dxf.DXFBase('localhost:5000', auth, (auth is None) or (do_token is None), None, tlsverify) r = dxf.DXF.from_base(base, pytest.repo) else: r = dxf.DXF('localhost:5000', pytest.repo, auth, (auth is None) or (do_token is None), None, tlsverify) r.test_do_auth = auth r.test_do_token = do_token r.regver = regver r.reg_digest = _get_registry_digest(regver) lex = Exception('should never be thrown') for _ in range(5): try: if do_token is None: with pytest.raises(dxf.exceptions.DXFAuthInsecureError): r.authenticate(pytest.username, pytest.password) return pytest.skip() assert not r.list_repos() return r except requests.exceptions.ConnectionError as ex: lex = ex time.sleep(1) raise lex
def dxf_obj(request): auth, do_token = _setup_fixture(request) r = dxf.DXF('localhost:5000', pytest.repo, auth, not auth) r.test_do_token = do_token for _ in range(5): try: assert r.list_repos() == [] return r except requests.exceptions.ConnectionError as ex: time.sleep(1) raise ex
def dxf_obj(request): # pylint: disable=redefined-outer-name regver, auth, do_token = _setup_fixture(request) r = dxf.DXF('localhost:5000', pytest.repo, auth, not auth) r.test_do_token = do_token r.regver = regver for _ in range(5): try: assert r.list_repos() == [] return r except requests.exceptions.ConnectionError as ex: time.sleep(1) raise ex
def dxf_obj(request): # pylint: disable=redefined-outer-name regver, auth, do_token, tlsverify = _setup_fixture(request) r = dxf.DXF('localhost:5000', pytest.repo, auth, (auth is None) or (do_token is None), None, tlsverify) r.test_do_auth = auth r.test_do_token = do_token r.regver = regver r.reg_digest = _get_registry_digest(regver) for _ in range(5): try: if do_token is None: with pytest.raises(dxf.exceptions.DXFAuthInsecureError): r.authenticate(pytest.username, pytest.password) return pytest.skip() assert r.list_repos() == [] return r except requests.exceptions.ConnectionError as ex: time.sleep(1) raise ex
def doit(args, environ): dxf_progress = environ.get('DXF_PROGRESS') if dxf_progress == '1' or (dxf_progress != '0' and sys.stderr.isatty()): bars = {} def progress(dgst, chunk, size): if dgst not in bars: bars[dgst] = tqdm.tqdm(desc=dgst[0:8], total=size, leave=True) if chunk: bars[dgst].update(len(chunk)) if bars[dgst].n >= bars[dgst].total: bars[dgst].close() del bars[dgst] else: progress = None def auth(dxf_obj, response): # pylint: disable=redefined-outer-name username = environ.get('DXF_USERNAME') password = environ.get('DXF_PASSWORD') authorization = environ.get('DXF_AUTHORIZATION') dxf_obj.authenticate(username, password, response=response, authorization=authorization) args = _parser.parse_args(args) if args.op != 'list-repos': dxf_obj = dxf.DXF(environ['DXF_HOST'], args.repo, auth, environ.get('DXF_INSECURE') == '1', environ.get('DXF_AUTH_HOST')) else: dxf_obj = dxf.DXFBase(environ['DXF_HOST'], auth, environ.get('DXF_INSECURE') == '1', environ.get('DXF_AUTH_HOST')) def _doit(): # pylint: disable=too-many-branches if args.op == "auth": username = environ.get('DXF_USERNAME') password = environ.get('DXF_PASSWORD') authorization = environ.get('DXF_AUTHORIZATION') token = dxf_obj.authenticate(username, password, actions=args.args, authorization=authorization) if token: print(token) return token = environ.get('DXF_TOKEN') if token: dxf_obj.token = token if args.op == "push-blob": if len(args.args) < 1: _parser.error('too few arguments') if len(args.args) > 2: _parser.error('too many arguments') if len(args.args) == 2 and not args.args[1].startswith('@'): _parser.error('invalid alias') dgst = dxf_obj.push_blob(args.args[0], progress) if len(args.args) == 2: dxf_obj.set_alias(args.args[1][1:], dgst) print(dgst) elif args.op == "pull-blob": _stdout = getattr(sys.stdout, 'buffer', sys.stdout) if args.args: dgsts = _flatten([ dxf_obj.get_alias(name[1:]) if name.startswith('@') else [name] for name in args.args ]) else: dgsts = dxf_obj.get_alias(manifest=sys.stdin.read()) for dgst in dgsts: it, size = dxf_obj.pull_blob( dgst, size=True, chunk_size=environ.get('DXF_CHUNK_SIZE')) if environ.get('DXF_BLOB_INFO') == '1': print(dgst + ' ' + str(size)) if progress: progress(dgst, b'', size) for chunk in it: if progress: progress(dgst, chunk, size) _stdout.write(chunk) elif args.op == 'blob-size': if args.args: sizes = [ dxf_obj.get_alias(name[1:], sizes=True) if name.startswith('@') else [(name, dxf_obj.blob_size(name))] for name in args.args ] else: sizes = [ dxf_obj.get_alias(manifest=sys.stdin.read(), sizes=True) ] for tuples in sizes: print(sum([size for _, size in tuples])) elif args.op == 'del-blob': if args.args: dgsts = _flatten([ dxf_obj.del_alias(name[1:]) if name.startswith('@') else [name] for name in args.args ]) else: dgsts = dxf_obj.get_alias(manifest=sys.stdin.read()) for dgst in dgsts: dxf_obj.del_blob(dgst) elif args.op == "set-alias": if len(args.args) < 2: _parser.error('too few arguments') dgsts = [ dxf.hash_file(dgst) if os.sep in dgst else dgst for dgst in args.args[1:] ] sys.stdout.write(dxf_obj.set_alias(args.args[0], *dgsts)) elif args.op == "get-alias": if args.args: dgsts = _flatten( [dxf_obj.get_alias(name) for name in args.args]) else: dgsts = dxf_obj.get_alias(manifest=sys.stdin.read()) for dgst in dgsts: print(dgst) elif args.op == "del-alias": for name in args.args: for dgst in dxf_obj.del_alias(name): print(dgst) elif args.op == 'list-aliases': if args.args: _parser.error('too many arguments') for name in dxf_obj.list_aliases(): print(name) elif args.op == 'list-repos': for name in dxf_obj.list_repos(): print(name) try: _doit() return 0 except dxf.exceptions.DXFUnauthorizedError: traceback.print_exc() return errno.EACCES except requests.exceptions.HTTPError as ex: # pylint: disable=no-member if ex.response.status_code == requests.codes.not_found: traceback.print_exc() return errno.ENOENT raise
# Paths and naming now = datetime.datetime.now() date = '%02d%02d%02d_%02d%02d' % (now.year, now.month, now.day, now.hour, now.minute) # the directory where we save the dxf file, change to be wherever you want to save it rootdir = './dxfparts/' # Parameters rplate = 100 * 0.5 # mm rslug = 155.0 * 0.5 # mm 150->155mm rscrew = 3.92 rthread = 0.245 * 0.5 * 25.4 # mm dthread = 35.0 # mm nthreads = 5 # the dxf object is called 'dd' dd = dxf.DXF() dd.circle([0., 0.], rslug) dd.circle([0., 0.], rplate) # Make hole in center for attachment to rod dd.circle([0., 0.], rscrew) thetas = np.linspace(0, 2. * np.pi, nthreads + 1)[0:-1] for tt in thetas: dd.circle([dthread * np.cos(tt), dthread * np.sin(tt)], rthread) ################################### # Save it ################################### specstr = '_nthreads' + str(nthreads) + '_rplate{0:0.1f}'.format(rplate).replace('.', 'p') specstr += '_rslug{0:0.1f}'.format(rslug).replace('.', 'p')
chart = load(f, Loader) chartVersion = chart["version"] appVersion = chart["appVersion"] print(dir, chartVersion, image, appVersion) if "/" not in image: image = "library/" + image if image.count("/") == 1: image = "index.docker.io/" + image url = urlparse("https://" + image) try: dxf_obj = dxf.DXF(url.netloc, url.path[1:]) dxf_obj.authenticate(actions=['pull']) aliases = dxf_obj.list_aliases() highestSemver = appVersion for alias in aliases: if semver.VersionInfo.isvalid(alias): if semver.compare(highestSemver, alias) == -1: highestSemver = alias if appVersion == highestSemver: print(appVersion, "==", highestSemver, "skipping") continue print(appVersion, "<", highestSemver, "upgrading")