def test_scidb_afl_module(): """Testing all public methods in scidblib.scidb_afl.""" print '*** testing scidblib.scidb_afl...' class TmpArgs: def __init__(self): self.host = '' self.port = '' args = TmpArgs() iquery_cmd = scidb_afl.get_iquery_cmd(args) scidb_afl.execute_it_return_out_err('ls') scidb_afl.afl(iquery_cmd, 'list()') print 'time_afl(..., \'list()\') =', scidb_afl.time_afl( iquery_cmd, 'list()') print 'single_cell_afl(..., \'build(<v:int64>[i=0:0,1,0], 5)\', 1) =', \ scidb_afl.single_cell_afl(iquery_cmd, 'build(<v:int64>[i=0:0,1,0], 5)', 1) print 'single_cell_afl(..., \'apply(build(<v:int64>[i=0:0,1,0], 5), v2, 6)\', 2) =', \ scidb_afl.single_cell_afl(iquery_cmd, 'apply(build(<v:int64>[i=0:0,1,0], 5), v2, 6)', 2) print 'get_num_instances(...) =', scidb_afl.get_num_instances(iquery_cmd) print 'get_array_names(...) =', scidb_afl.get_array_names(iquery_cmd) print
def remove_arrays_by_prefix(self, prefix): names=scidb_afl.get_array_names(self._iquery_cmd) names_to_remove = [] for name in names: if name.startswith(prefix): names_to_remove.append(name) for name in names_to_remove: self.query('remove('+name+')')
def remove_arrays_by_prefix(self, prefix): names = scidb_afl.get_array_names(self._iquery_cmd) names_to_remove = [] for name in names: if name.startswith(prefix): names_to_remove.append(name) for name in names_to_remove: self.query('remove(' + name + ')')
def test_scidb_afl_module(): """Testing all public methods in scidblib.scidb_afl.""" print '*** testing scidblib.scidb_afl...' class TmpArgs: def __init__(self): self.host = '' self.port = '' args = TmpArgs() iquery_cmd = scidb_afl.get_iquery_cmd(args) scidb_afl.execute_it_return_out_err('ls') scidb_afl.afl(iquery_cmd, 'list()') print 'time_afl(..., \'list()\') =', scidb_afl.time_afl(iquery_cmd, 'list()') print 'single_cell_afl(..., \'build(<v:int64>[i=0:0,1,0], 5)\', 1) =', \ scidb_afl.single_cell_afl(iquery_cmd, 'build(<v:int64>[i=0:0,1,0], 5)', 1) print 'single_cell_afl(..., \'apply(build(<v:int64>[i=0:0,1,0], 5), v2, 6)\', 2) =', \ scidb_afl.single_cell_afl(iquery_cmd, 'apply(build(<v:int64>[i=0:0,1,0], 5), v2, 6)', 2) print 'get_num_instances(...) =', scidb_afl.get_num_instances(iquery_cmd) print 'get_array_names(...) =', scidb_afl.get_array_names(iquery_cmd) print
def main(): """The main function lists all arrays """ parser = argparse.ArgumentParser( description='List all scidb arrays.', epilog='Assumptions:\n' + ' - SciDB is running.\n' ' - The environment is setup to support namespaces.\n' ' - The iquery application is in your path.', formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-c', '--host', help='Host name to be passed to iquery.') parser.add_argument('-p', '--port', help='Port number to be passed to iquery.') parser.add_argument('-t', '--temp-only', action='store_true', help='Limiting the candidates to temp arrays.') parser.add_argument('-v', '--versions', help='Include all versions in the list.') parser.add_argument('-A', '--auth-file', help='Authentication file to be passed to iquery.') parser.add_argument('-s', '--sort-by', default='array', choices=['array', 'namespace'], help='Either array or namespace.') parser.add_argument('-f', '--find-array', help='find a particular array name.') args = parser.parse_args() try: arrays = [] iquery_cmd = scidb_afl.get_iquery_cmd(args) namespaces = scidb_afl.get_namespace_names(iquery_cmd) for namespace in namespaces: new_arrays = scidb_afl.get_array_names(iquery_cmd=iquery_cmd, temp_only=args.temp_only, versions=args.versions, namespace=namespace) for array in new_arrays: t = (array, namespace) arrays.append(t) if arrays: if args.find_array: result = [tup for tup in arrays if tup[0] == args.find_array] if not result: raise ValueError, 'array {0} not found'.format( args.find_array) array, namespace = result[0] print scidb_make_qualified_array_name('namespace', 'array') print scidb_make_qualified_array_name(namespace, array) else: print scidb_make_qualified_array_name('namespace', 'array') item = 0 if args.sort_by == 'namespace': item = 1 for (array, namespace) in sorted(arrays, key=itemgetter(item)): print scidb_make_qualified_array_name(namespace, array) else: print >> sys.stderr, 'No arrays found' except Exception, e: print >> sys.stderr, '------ Exception -----------------------------' print >> sys.stderr, e if _print_traceback_upon_exception: print >> sys.stderr, '------ Traceback (for debug purpose) ---------' traceback.print_exc() print >> sys.stderr, '----------------------------------------------' sys.exit(-1) # upon an exception, throw -1
def main(): """The main function gets command-line argument as a pattern, and removes all arrays with that pattern. """ parser = argparse.ArgumentParser( description='Remove all SciDB arrays whose names match a given pattern.', epilog= 'assumptions:\n' + ' - iquery is in your path.', formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-f', '--force', action='store_true', help='Forced removal of the arrays without asking for confirmation.') parser.add_argument('-c', '--host', help='Host name to be passed to iquery.') parser.add_argument('-p', '--port', help='Port number to be passed to iquery.') parser.add_argument('-t', '--temp-only', action='store_true', help='Limiting the candidates to temp arrays.') parser.add_argument('-U', '--user-name', help='User name to be passed to iquery.') parser.add_argument('-P', '--user-password', help='User password to be passed to iquery.') parser.add_argument('-v', '--verbose ', default=True, help='display verbose output.') parser.add_argument('regex', metavar='REGEX', type=str, nargs='?', default='.*', help='''Regular expression to match against array names. The utility will remove arrays whose names match the regular expression. Default is '.+', meaning to remove all arrays, because the pattern matches all names. The regular expression must match the full array name. For instance, '.*s' will match array 'dogs' because it ends with 's', but will not match array 'moose' because it does not end with 's'.''' ) args = parser.parse_args() try: iquery_cmd = scidb_afl.get_iquery_cmd(args) namespaces = scidb_afl.get_namespace_names(iquery_cmd) for namespace in namespaces: print "\nSearching namespace: ", namespace names = scidb_afl.get_array_names( iquery_cmd = iquery_cmd, temp_only=args.temp_only, namespace=namespace) names_to_remove = [] for name in names: match_name = re.match('^'+args.regex+'$', name) if match_name: names_to_remove.append(name) if not names_to_remove: print "There are no arrays to remove in namespace", namespace continue if not args.force: print 'The following arrays are about to be removed from namespace ' + namespace + ':' print names_to_remove proceed = scidb_psf.confirm(prompt='Are you sure you want to remove?', resp=False) if not proceed: return for name in names_to_remove: scidb_afl.remove_array(name, namespace, iquery_cmd) if namespace != 'public': names = scidb_afl.get_array_names( iquery_cmd=iquery_cmd, temp_only=args.temp_only, namespace=namespace) if not names: scidb_afl.afl( iquery_cmd, 'drop_namespace(\'' + namespace + '\');') print "namespace " + namespace + " removed" print 'Number of arrays removed =', len(names_to_remove) except Exception, e: print >> sys.stderr, '------ Exception -----------------------------' print >> sys.stderr, e if args.verbose: print >> sys.stderr, '------ Traceback (for debug purpose) ---------' traceback.print_exc() print >> sys.stderr, '----------------------------------------------' sys.exit(-1) # upon an exception, throw -1
def main(): """The main function lists all arrays """ parser = argparse.ArgumentParser( description='List all scidb arrays.', epilog= 'Assumptions:\n' + ' - SciDB is running.\n' ' - The environment is setup to support namespaces.\n' ' - The iquery application is in your path.', formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-c', '--host', help='Host name to be passed to iquery.') parser.add_argument('-p', '--port', help='Port number to be passed to iquery.') parser.add_argument('-t', '--temp-only', action='store_true', help='Limiting the candidates to temp arrays.') parser.add_argument('-v', '--versions', help='Include all versions in the list.') parser.add_argument('-A', '--auth-file', help='Authentication file to be passed to iquery.') parser.add_argument('-s', '--sort-by', default='array', choices=['array', 'namespace'], help='Either array or namespace.') parser.add_argument('-f', '--find-array', help='find a particular array name.') args = parser.parse_args() try: arrays = [] iquery_cmd = scidb_afl.get_iquery_cmd(args) namespaces = scidb_afl.get_namespace_names(iquery_cmd) for namespace in namespaces: new_arrays = scidb_afl.get_array_names( iquery_cmd=iquery_cmd, temp_only=args.temp_only, versions=args.versions, namespace=namespace) for array in new_arrays: t=(array, namespace) arrays.append(t) if arrays: if args.find_array: result=[tup for tup in arrays if tup[0] == args.find_array] if not result: raise ValueError, 'array {0} not found'.format(args.find_array) array, namespace = result[0] print scidb_make_qualified_array_name('namespace', 'array') print scidb_make_qualified_array_name(namespace, array) else: print scidb_make_qualified_array_name('namespace', 'array') item=0 if args.sort_by == 'namespace': item=1 for (array, namespace) in sorted(arrays, key=itemgetter(item)): print scidb_make_qualified_array_name(namespace, array) else: print >> sys.stderr, 'No arrays found' except Exception, e: print >> sys.stderr, '------ Exception -----------------------------' print >> sys.stderr, e if _print_traceback_upon_exception: print >> sys.stderr, '------ Traceback (for debug purpose) ---------' traceback.print_exc() print >> sys.stderr, '----------------------------------------------' sys.exit(-1) # upon an exception, throw -1
def main(): """The main function gets command-line argument as a pattern, and removes all arrays with that pattern. """ parser = argparse.ArgumentParser( description= 'Remove all SciDB arrays whose names match a given pattern.', epilog='assumptions:\n' + ' - iquery is in your path.', formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument( '-f', '--force', action='store_true', help='Forced removal of the arrays without asking for confirmation.') parser.add_argument('-c', '--host', help='Host name to be passed to iquery.') parser.add_argument('-p', '--port', help='Port number to be passed to iquery.') parser.add_argument('-t', '--temp-only', action='store_true', help='Limiting the candidates to temp arrays.') parser.add_argument('-U', '--user-name', help='User name to be passed to iquery.') parser.add_argument('-P', '--user-password', help='User password to be passed to iquery.') parser.add_argument('-v', '--verbose ', default=True, help='display verbose output.') parser.add_argument( 'regex', metavar='REGEX', type=str, nargs='?', default='.*', help='''Regular expression to match against array names. The utility will remove arrays whose names match the regular expression. Default is '.+', meaning to remove all arrays, because the pattern matches all names. The regular expression must match the full array name. For instance, '.*s' will match array 'dogs' because it ends with 's', but will not match array 'moose' because it does not end with 's'.''' ) args = parser.parse_args() try: iquery_cmd = scidb_afl.get_iquery_cmd(args) namespaces = scidb_afl.get_namespace_names(iquery_cmd) for namespace in namespaces: print "\nSearching namespace: ", namespace names = scidb_afl.get_array_names(iquery_cmd=iquery_cmd, temp_only=args.temp_only, namespace=namespace) names_to_remove = [] for name in names: match_name = re.match('^' + args.regex + '$', name) if match_name: names_to_remove.append(name) if not names_to_remove: print "There are no arrays to remove in namespace", namespace continue if not args.force: print 'The following arrays are about to be removed from namespace ' + namespace + ':' print names_to_remove proceed = scidb_psf.confirm( prompt='Are you sure you want to remove?', resp=False) if not proceed: return for name in names_to_remove: scidb_afl.remove_array(name, namespace, iquery_cmd) if namespace != 'public': names = scidb_afl.get_array_names(iquery_cmd=iquery_cmd, temp_only=args.temp_only, namespace=namespace) if not names: scidb_afl.afl(iquery_cmd, 'drop_namespace(\'' + namespace + '\');') print "namespace " + namespace + " removed" print 'Number of arrays removed =', len(names_to_remove) except Exception, e: print >> sys.stderr, '------ Exception -----------------------------' print >> sys.stderr, e if args.verbose: print >> sys.stderr, '------ Traceback (for debug purpose) ---------' traceback.print_exc() print >> sys.stderr, '----------------------------------------------' sys.exit(-1) # upon an exception, throw -1
def main(): """The main function gets command-line argument as a pattern, and removes all arrays with that pattern. @exception AppError if something goes wrong. @note If print_traceback_upon_exception (defined at the top of the script) is True, stack trace will be printed. This is helpful during debugging. """ parser = argparse.ArgumentParser( description= 'Remove all SciDB arrays whose names match a given pattern.', epilog='assumptions:\n' + ' - iquery is in your path.', formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument( '-f', '--force', action='store_true', help='Forced removal of the arrays without asking for confirmation.') parser.add_argument('-c', '--host', help='Host name to be passed to iquery.') parser.add_argument('-p', '--port', help='Port number to be passed to iquery.') parser.add_argument('-t', '--temp-only', action='store_true', help='Limiting the candidates to temp arrays.') parser.add_argument( 'regex', metavar='REGEX', type=str, nargs='?', default='.*', help='''Regular expression to match against array names. The utility will remove arrays whose names match the regular expression. Default is '.+', meaning to remove all arrays, because the pattern matches all names. The regular expression must match the full array name. For instance, '.*s' will match array 'dogs' because it ends with 's', but will not match array 'moose' because it does not end with 's'.''' ) args = parser.parse_args() try: names = scidb_afl.get_array_names(temp_only=args.temp_only) iquery_cmd = scidb_afl.get_iquery_cmd(args) names_to_remove = [] for name in names: match_name = re.match('^' + args.regex + '$', name) if match_name: names_to_remove.append(name) if not names_to_remove: print 'There is no array to remove.' sys.exit(0) if not args.force: print 'The following arrays are about to be removed:' print names_to_remove proceed = scidb_psf.confirm( prompt='Are you sure you want to remove?', resp=False) if not proceed: sys.exit(0) for name in names_to_remove: scidb_afl.afl(iquery_cmd, 'remove(' + name + ')') print 'Number of arrays removed =', len(names_to_remove) except Exception, e: print >> sys.stderr, '------ Exception -----------------------------' print >> sys.stderr, e if _print_traceback_upon_exception: print >> sys.stderr, '------ Traceback (for debug purpose) ---------' traceback.print_exc() print >> sys.stderr, '----------------------------------------------' sys.exit(-1) # upon an exception, throw -1
def main(): """The main function gets command-line argument as a pattern, and removes all arrays with that pattern. @exception AppError if something goes wrong. @note If print_traceback_upon_exception (defined at the top of the script) is True, stack trace will be printed. This is helpful during debugging. """ parser = argparse.ArgumentParser( description='Remove all SciDB arrays whose names match a given pattern.', epilog= 'assumptions:\n' + ' - iquery is in your path.', formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-f', '--force', action='store_true', help='Forced removal of the arrays without asking for confirmation.') parser.add_argument('-c', '--host', help='Host name to be passed to iquery.') parser.add_argument('-p', '--port', help='Port number to be passed to iquery.') parser.add_argument('-t', '--temp-only', action='store_true', help='Limiting the candidates to temp arrays.') parser.add_argument('regex', metavar='REGEX', type=str, nargs='?', default='.*', help='''Regular expression to match against array names. The utility will remove arrays whose names match the regular expression. Default is '.+', meaning to remove all arrays, because the pattern matches all names. The regular expression must match the full array name. For instance, '.*s' will match array 'dogs' because it ends with 's', but will not match array 'moose' because it does not end with 's'.''' ) args = parser.parse_args() try: names = scidb_afl.get_array_names(temp_only=args.temp_only) iquery_cmd = scidb_afl.get_iquery_cmd(args) names_to_remove = [] for name in names: match_name = re.match('^'+args.regex+'$', name) if match_name: names_to_remove.append(name) if not names_to_remove: print 'There is no array to remove.' sys.exit(0) if not args.force: print 'The following arrays are about to be removed:' print names_to_remove proceed = scidb_psf.confirm(prompt='Are you sure you want to remove?', resp=False) if not proceed: sys.exit(0) for name in names_to_remove: scidb_afl.afl(iquery_cmd, 'remove('+name+')') print 'Number of arrays removed =', len(names_to_remove) except Exception, e: print >> sys.stderr, '------ Exception -----------------------------' print >> sys.stderr, e if _print_traceback_upon_exception: print >> sys.stderr, '------ Traceback (for debug purpose) ---------' traceback.print_exc() print >> sys.stderr, '----------------------------------------------' sys.exit(-1) # upon an exception, throw -1
def main(): """The main function gets command-line argument as a pattern, and removes all arrays with that pattern. Note: Empty namespaces will NOT be removed. """ parser = argparse.ArgumentParser( description= 'Remove all SciDB arrays whose names match a given pattern.', epilog='assumptions:\n' + ' - iquery is in your path.', formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument( '-f', '--force', action='store_true', help='Forced removal of the arrays without asking for confirmation.') parser.add_argument('-c', '--host', help='Host name to be passed to iquery.') parser.add_argument('-p', '--port', help='Port number to be passed to iquery.') parser.add_argument('-t', '--temp-only', action='store_true', help='Limiting the candidates to temp arrays.') parser.add_argument('-A', '--auth-file', help='Authentication file to be passed to iquery.') parser.add_argument( '-U', '--user-name', help= 'Deprecated: Use --auth-file instead. User name to be passed to iquery.' ) parser.add_argument( '-P', '--user-password', help= 'Deprecated: Use --auth-file instead. User password to be passed to iquery.' ) parser.add_argument('-v', '--verbose', default=True, help='display verbose output.') parser.add_argument( 'regex', metavar='REGEX', type=str, nargs='?', default='.*', help='''Regular expression to match against array names. The utility will remove arrays whose names match the regular expression. Default is '.+', meaning to remove all arrays, because the pattern matches all names. The regular expression must match the full array name. For instance, '.*s' will match array 'dogs' because it ends with 's', but will not match array 'moose' because it does not end with 's'.''' ) _temp_auth_file = None _arrays_removed = 0 args = parser.parse_args() try: if args.verbose == True: print >> sys.stderr, "args={0}".format(args) if args.user_name and args.user_password and (args.auth_file == None): print >> sys.stderr, '\nWARNING: --user-name and --user-password are deprecated. Use --auth-file instead.\n' _temp_auth_file = create_auth_file(args.user_name, args.user_password) args.auth_file = _temp_auth_file.name args.user_name = None args.user_password = None iquery_cmd = scidb_afl.get_iquery_cmd(args) namespaces = scidb_afl.get_namespace_names(iquery_cmd) if args.verbose == True: print >> sys.stderr, "namespaces={0}".format(namespaces) _arrays_removed = 0 for namespace in namespaces: if args.verbose == True: print >> sys.stderr, "\nSearching namespace: ", namespace names = scidb_afl.get_array_names(iquery_cmd=iquery_cmd, temp_only=args.temp_only, namespace=namespace) if args.verbose == True: print >> sys.stderr, "names={0}".format(names) names_to_remove = [] for name in names: match_name = re.match('^' + args.regex + '$', name) if match_name: if args.verbose == True: print >> sys.stderr, "Schedule {0}.{1} to be removed".format( namespace, name) names_to_remove.append(name) if not names_to_remove: if args.verbose == True: print "There are no arrays to remove in namespace", namespace continue if not args.force: print 'The following arrays are about to be removed from namespace {0}:'.format( namespace) print names_to_remove proceed = scidb_psf.confirm( prompt='Are you sure you want to remove?', resp=False) if not proceed: return for name in names_to_remove: scidb_afl.remove_array(name, namespace, iquery_cmd) if args.verbose == True: print >> sys.stderr, "array {0}.{1} removed".format( namespace, name) _arrays_removed += 1 if namespace != 'public': names = scidb_afl.get_array_names(iquery_cmd=iquery_cmd, temp_only=args.temp_only, namespace=namespace) if not names: scidb_afl.afl(iquery_cmd, "drop_namespace('{0}');".format(namespace)) if args.verbose == True: print >> sys.stderr, "namespace {0} removed".format( namespace) if args.verbose == True: print >> sys.stderr, 'Number of arrays removed =', _arrays_removed if _temp_auth_file: _temp_auth_file.close() _temp_auth_file = None except Exception, e: print >> sys.stderr, '------ Exception -----------------------------' print >> sys.stderr, e if args.verbose == True: print >> sys.stderr, 'Number of arrays removed =', _arrays_removed if args.verbose == True: print >> sys.stderr, '------ Traceback (for debug purpose) ---------' traceback.print_exc() if _temp_auth_file: _temp_auth_file.close() _temp_auth_file = None print >> sys.stderr, '----------------------------------------------' sys.exit(-1) # upon an exception, throw -1