def library_list(): if request.method == 'PUT': data = json.loads(request.get_data().decode("utf8")) Library.add(data['name'], data['path'], data['lib_type'], '', '', '') return json_return({'message': "添加成功"}) full = request.args.get("full", "false") == 'true' with Database() as db: rows = db.select( "select id,name,lib_type,dir,status,version from library order by id", dict_result=True) if not full: return json_return(rows) result = { row['id']: { 'id': row['id'], 'name': row['name'], 'lib_type': row['lib_type'], 'dir': row['dir'], 'status': row['status'], 'version': row['version'], 'count': 0, 'next_count': 0 } for row in rows } item_sql = "select library_id,version,count(1) c from item group by library_id,version" item_rows = db.select(item_sql, dict_result=True) for row in item_rows: if row['version'] == result[row['library_id']]['version']: result[row['library_id']]['count'] = row['c'] else: result[row['library_id']]['next_count'] = row['c'] return json_return([item for item in result.values()])
def package(name, type, title, order, layer, library, require): global _libraries, _packages sm = getGlobalSiteManager() # create marker interface marker = _libraries.get((library, type)) if marker is None: uid = str(random.randint(0, 9999999)) marker = InterfaceClass('IPackage%s'%uid, (interface.Interface,), __doc__='Package: %s' %name, __module__='zojax.resourcepackage') _libraries[(library, type)] = marker # check if package already registered packageInfo = None for (_layer, _library, _type), _packageInfo in _packages.items(): if _library == library and layer.isOrExtends(_layer) and _type == type: packageInfo = _packageInfo if packageInfo is not None: # register library if library: lib = sm.queryUtility(ILibrary, name=library) if lib is None: lib = Library(library) handler('registerUtility', lib, ILibrary, library) lib.add(name, require) return # create package package = getUtility(IPackageFactory, type)(name, order, title) interface.directlyProvides(package, marker) factory = Factory(package) # register resource sm.registerAdapter(factory, (layer, ), interface.Interface, name) sm.registerAdapter(factory, (layer, ), IPackage, name) # register package info packageInfo = PackageInfo(library, layer, marker, package) _packages[(layer, library, type)] = packageInfo # register library if library: lib = sm.queryUtility(ILibrary, name=library) if lib is None: lib = Library(library) handler('registerUtility', lib, ILibrary, library) lib.add(name, require)
from hash import Hash from library import Library master = Library() client = Hash() client.inputUsername() client.inputPass() master.add(client) print("\n") master.printLib() check = Hash() logUse = input("Log in username: "******"Log in password: "******"\n") print(foundAccount.retHash()) print(check.retHash())