From 46131551c0bd8603e10fc76364e5e77c3a0fcb02 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 26 Oct 2020 11:34:28 -0400 Subject: [PATCH] LP1827055 Remove Python libs, install bits, and docs Signed-off-by: Bill Erickson Signed-off-by: Jason Stephenson Signed-off-by: Chris Sharp --- Open-ILS/src/Makefile.am | 10 +- Open-ILS/src/extras/eg_config.in | 5 - Open-ILS/src/python/Makefile.am | 13 - Open-ILS/src/python/oils/__init__.py | 0 Open-ILS/src/python/oils/const.py | 32 -- Open-ILS/src/python/oils/event.py | 66 ---- Open-ILS/src/python/oils/org.py | 163 ---------- Open-ILS/src/python/oils/srfsh.py | 130 -------- Open-ILS/src/python/oils/system.py | 44 --- Open-ILS/src/python/oils/utils/__init__.py | 0 Open-ILS/src/python/oils/utils/csedit.py | 275 ----------------- Open-ILS/src/python/oils/utils/idl.py | 288 ------------------ Open-ILS/src/python/oils/utils/utils.py | 83 ----- Open-ILS/src/python/setup.py | 13 - Open-ILS/src/support-scripts/brick_ctl.sh | 2 +- .../support-scripts/test-scripts/acq_fund.py | 41 --- build/tools/script_x_check.sh | 10 +- configure.ac | 21 +- 18 files changed, 4 insertions(+), 1192 deletions(-) delete mode 100644 Open-ILS/src/python/Makefile.am delete mode 100644 Open-ILS/src/python/oils/__init__.py delete mode 100644 Open-ILS/src/python/oils/const.py delete mode 100644 Open-ILS/src/python/oils/event.py delete mode 100644 Open-ILS/src/python/oils/org.py delete mode 100644 Open-ILS/src/python/oils/srfsh.py delete mode 100644 Open-ILS/src/python/oils/system.py delete mode 100644 Open-ILS/src/python/oils/utils/__init__.py delete mode 100644 Open-ILS/src/python/oils/utils/csedit.py delete mode 100644 Open-ILS/src/python/oils/utils/idl.py delete mode 100644 Open-ILS/src/python/oils/utils/utils.py delete mode 100755 Open-ILS/src/python/setup.py delete mode 100755 Open-ILS/src/support-scripts/test-scripts/acq_fund.py diff --git a/Open-ILS/src/Makefile.am b/Open-ILS/src/Makefile.am index 0f86c3620a..f31ac85b87 100644 --- a/Open-ILS/src/Makefile.am +++ b/Open-ILS/src/Makefile.am @@ -108,14 +108,6 @@ reporter_data = @srcdir@/reporter/report-fail \ @srcdir@/reporter/report-success endif -#------------------------------ -# Build EVERGREEN PYTHON -#------------------------------ - -if BUILDEGPYTHON -OILSPYTHON_DIR = python -endif - #------------------------------ # Build EVERGREEN JAVA #------------------------------ @@ -158,7 +150,7 @@ doc_DATA = $(gen_docs) # Take care of which subdirectories to build, and which extra files to include in a distribution. -SUBDIRS = $(OILSCORE_DIRS) $(OILSWEB_DIR) $(OILSPYTHON_DIR) $(OILSJAVA_DIR) +SUBDIRS = $(OILSCORE_DIRS) $(OILSWEB_DIR) $(OILSJAVA_DIR) EXTRA_DIST = @srcdir@/perlmods \ @srcdir@/data \ diff --git a/Open-ILS/src/extras/eg_config.in b/Open-ILS/src/extras/eg_config.in index 6f37ef688f..5cdbfcd869 100644 --- a/Open-ILS/src/extras/eg_config.in +++ b/Open-ILS/src/extras/eg_config.in @@ -36,11 +36,6 @@ function showInstalled { if test "@BUILDEGJAVA_TRUE@" = ""; then echo "EG_JAVA" fi - if test "@BUILDEGPYTHON_TRUE@" = ""; then - echo "EG_PYTHON" - fi - - } function showAll { diff --git a/Open-ILS/src/python/Makefile.am b/Open-ILS/src/python/Makefile.am deleted file mode 100644 index 4e7cdb9377..0000000000 --- a/Open-ILS/src/python/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -# makefile for OpenSRF Python modules and scripts - -all-local: - @echo $@ - python @srcdir@/setup.py build - -# ------------------------------------------------------------------------------ -# INSTALL -# ------------------------------------------------------------------------------ -install-data-local: - @echo $@ - python @srcdir@/setup.py install --root $(DESTDIR)/// - diff --git a/Open-ILS/src/python/oils/__init__.py b/Open-ILS/src/python/oils/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/Open-ILS/src/python/oils/const.py b/Open-ILS/src/python/oils/const.py deleted file mode 100644 index 2c4d240c5a..0000000000 --- a/Open-ILS/src/python/oils/const.py +++ /dev/null @@ -1,32 +0,0 @@ -""" -Defines Evergreen constants, including namespaces, events, and services - -The OILS prefix derives from Evergreen's old working title, Open-ILS. -""" -# ----------------------------------------------------------------------- -# Copyright (C) 2007 Georgia Public Library Service -# Bill Erickson -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# ----------------------------------------------------------------------- - -OILS_NS_OBJ = 'http://open-ils.org/spec/opensrf/IDL/objects/v1' -OILS_NS_PERSIST = 'http://open-ils.org/spec/opensrf/IDL/persistence/v1' -OILS_NS_REPORTER = 'http://open-ils.org/spec/opensrf/IDL/reporter/v1' - -OILS_EVENT_SUCCESS = 'SUCCESS' - -OILS_APP_AUTH = 'open-ils.auth' -OILS_APP_CIRC = 'open-ils.circ' -OILS_APP_CSTORE = 'open-ils.cstore' -OILS_APP_SEARCH = 'open-ils.search' -OILS_APP_ACQ = 'open-ils.acq' -OILS_APP_ACTOR = 'open-ils.actor' diff --git a/Open-ILS/src/python/oils/event.py b/Open-ILS/src/python/oils/event.py deleted file mode 100644 index c87f393724..0000000000 --- a/Open-ILS/src/python/oils/event.py +++ /dev/null @@ -1,66 +0,0 @@ -import osrf.ex - -class Event(object): - ''' Generic ILS event object ''' - - def __init__(self, evt_hash={}): - try: - self.code = int(evt_hash['ilsevent']) - except: - self.code = -1 - self.text_code = evt_hash['textcode'] - self.desc = evt_hash.get('desc') or '' - self.payload = evt_hash.get('payload') - self.debug = evt_hash.get('stacktrace') or '' - self.servertime = evt_hash.get('servertime') or '' - self.ilsperm = evt_hash.get('ilsperm') - self.ilspermloc = evt_hash.get('ilspermloc') - - self.success = False - if self.code == 0: - self.success = True - - def __str__(self): - if self.ilsperm: - return '%s: %s:%s -> %s %s@%s' % ( - self.__class__.__name__, self.code, self.text_code, self.desc, self.ilsperm, str(self.ilspermloc)) - else: - return '%s: %s:%s -> %s' % ( - self.__class__.__name__, self.code, self.text_code, self.desc) - - # XXX eventually, add events file parsing... - - def to_ex(self): - return EventException(unicode(self)) - - - @staticmethod - def parse_event(evt=None): - ''' If the provided evt object is a dictionary object that looks - like an ILS event, construct an Event object and return it. - Returns None otherwise. ''' - - if isinstance(evt, dict) and 'ilsevent' in evt and 'textcode' in evt: - return Event(evt) - - return None - - @staticmethod - def parse_and_raise(obj=None): - ''' Parses with parse_event. If the resulting event is a non-success - event, it is converted to an exception and raised. If the resulting - event is a success event, the event object is returned. If the - object is not an event, the original original object is returned - unchanged. ''' - evt = Event.parse_event(obj) - if evt: - if evt.success: - return evt - raise evt.to_ex() - return obj - - -class EventException(osrf.ex.OSRFException): - ''' A throw-able exception wrapper for events ''' - pass - diff --git a/Open-ILS/src/python/oils/org.py b/Open-ILS/src/python/oils/org.py deleted file mode 100644 index c37c9c7a6c..0000000000 --- a/Open-ILS/src/python/oils/org.py +++ /dev/null @@ -1,163 +0,0 @@ -import osrf.ses -import oils.event, oils.const -import sys - -class OrgUtil(object): - ''' Collection of general purpose org_unit utility functions ''' - - _org_tree = None - _org_types = None - _flat_org_tree = {} - - @staticmethod - def _verify_tree(): - if not OrgUtil._org_tree: - OrgUtil.fetch_org_tree() - - @staticmethod - def fetch_org_tree(): - ''' Returns the whole org_unit tree ''' - - if OrgUtil._org_tree: - return OrgUtil._org_tree - - tree = osrf.ses.ClientSession.atomic_request( - oils.const.OILS_APP_ACTOR, - 'open-ils.actor.org_tree.retrieve') - - oils.event.Event.parse_and_raise(tree) - OrgUtil._org_tree = tree - OrgUtil.flatten_org_tree(tree) - return tree - - @staticmethod - def flatten_org_tree(node): - ''' Creates links from an ID-based hash to the org units in the org tree ''' - if not node: - node = OrgUtil._org_tree - OrgUtil._flat_org_tree[int(node.id())] = node - for child in node.children(): - OrgUtil.flatten_org_tree(child) - - @staticmethod - def get_org_unit(org_id): - OrgUtil._verify_tree() - if isinstance(org_id, osrf.net_obj.NetworkObject): - return org_id - return OrgUtil._flat_org_tree[int(org_id)] - - - @staticmethod - def fetch_org_types(): - ''' Returns the list of org_unit_type objects ''' - - if OrgUtil._org_types: - return OrgUtil._org_types - - types = osrf.ses.ClientSession.atomic_request( - oils.const.OILS_APP_ACTOR, 'open-ils.actor.org_types.retrieve') - - oils.event.Event.parse_and_raise(types) - OrgUtil._org_types = types - return types - - - @staticmethod - def get_org_type(org_unit): - ''' Given an org_unit, this returns the org_unit_type object it's linked to ''' - types = OrgUtil.fetch_org_types() - return [t for t in types if t.id() == org_unit.ou_type()][0] - - - @staticmethod - def get_related_tree(org_unit): - ''' Returns a cloned tree of orgs including all ancestors and - descendants of the provided org ''' - - OrgUtil._verify_tree() - org = org_unit = OrgUtil.get_org_unit(org_unit.id()).shallow_clone() - while org.parent_ou(): - parent = org.parent_ou() - if not isinstance(parent, osrf.net_obj.NetworkObject): - parent = OrgUtil._flat_org_tree[parent] - parent = parent.shallow_clone() - parent.children([org]) - org = parent - root = org - - def trim_org(node): - node = node.shallow_clone() - children = node.children() - if len(children) > 0: - node.children([]) - for child in children: - node.children().append(trim_org(child)) - return node - - trim_org(org_unit) - return root - - @staticmethod - def get_union_tree(org_id_list): - ''' Returns the smallest org tree which encompases all of the orgs in org_id_list ''' - - OrgUtil._verify_tree() - if len(org_id_list) == 0: - return None - main_tree = OrgUtil.get_related_tree(OrgUtil.get_org_unit(org_id_list[0])) - - if len(org_id_list) == 1: - return main_tree - - for org in org_id_list[1:]: - node = OrgUtil.get_related_tree(OrgUtil.get_org_unit(org)) - main_node = main_tree - - while node.id() == main_node.id(): - child = node.children()[0] - main_child_node = main_node.children()[0] - child.parent_ou(node) - main_child_node.parent_ou(main_node) - node = child - main_node = main_child_node - - main_node.parent_ou().children().append(node) - - return main_tree - - @staticmethod - def get_related_list(org_unit): - ''' Returns a flat list of related org_units ''' - OrgUtil._verify_tree() - tree = OrgUtil.get_related_tree(org_unit) - orglist = [] - def flatten(node): - orglist.append(node) - for child in node.children(): - flatten(child) - flatten(tree) - return orglist - - @staticmethod - def get_min_depth(org_id_list): - ''' Returns the minimun depth (highest tree position) of all orgs in the list ''' - depth = None - for org in org_id_list: - new_depth = OrgUtil.get_org_type(OrgUtil.get_org_unit(org)).depth() - if depth is None: - depth = new_depth - elif new_depth < depth: - depth = new_depth - return depth - - @staticmethod - def debug_tree(org_unit, indent=0): - ''' Simple function to print the tree of orgs provided ''' - for i in range(indent): - sys.stdout.write('_') - print '%s id=%s depth=%s' % (org_unit.shortname(), str(org_unit.id()), str(OrgUtil.get_org_type(org_unit).depth())) - indent += 1 - for child in org_unit.children(): - OrgUtil.debug_tree(child, indent) - - diff --git a/Open-ILS/src/python/oils/srfsh.py b/Open-ILS/src/python/oils/srfsh.py deleted file mode 100644 index df8072c57f..0000000000 --- a/Open-ILS/src/python/oils/srfsh.py +++ /dev/null @@ -1,130 +0,0 @@ -# ----------------------------------------------------------------------- -# Copyright (C) 2010 Equinox Software, Inc. -# Bill Erickson -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# ----------------------------------------------------------------------- -import oils.utils.idl -from oils.utils.utils import md5sum -import osrf.json - -def handle_login(srfsh, args): - ''' Login w/ args ''' - - username = args[0] - password = args[1] - - seed = srfsh.handle_request([ - 'open-ils.auth', - 'open-ils.auth.authenticate.init', - '"%s"' % username - ]) - - password = md5sum(seed + md5sum(password)) - - response = srfsh.handle_request([ - 'open-ils.auth', - 'open-ils.auth.authenticate.complete', - - osrf.json.to_json( - { # handle_request accepts json-encoded params - 'username' : username, - 'password' : password, - 'type' : args[2] if len(args) > 2 else None, - 'workstation' : args[3] if len(args) > 3 else None - } - ) - ]) - -def handle_auth_verify(srfsh, args): - ''' Verify auth w/ args ''' - - username = args[0] - password = args[1] - - seed = srfsh.handle_request([ - 'open-ils.auth', - 'open-ils.auth.authenticate.init', - '"%s"' % username - ]) - - password = md5sum(seed + md5sum(password)) - - response = srfsh.handle_request([ - 'open-ils.auth', - 'open-ils.auth.authenticate.verify', - - osrf.json.to_json( - { # handle_request accepts json-encoded params - 'username' : username, - 'password' : password, - 'type' : args[2] if len(args) > 2 else None, - } - ) - ]) - - -def handle_org_setting(srfsh, args): - ''' Retrieves the requested org setting. - - Arguments: - org unit id, - org setting name - ''' - - org_unit = args[0] - setting = args[1] - - srfsh.handle_request([ - 'open-ils.actor', - 'open-ils.actor.ou_setting.ancestor_default', - org_unit, - ',"%s"' % setting - ]) - -def handle_idl(srfsh, args): - ''' Handles the 'idl' command. - - Argument options inlude: - idl show class - ''' - - # all IDL commands require the IDL to be present - if oils.utils.idl.IDLParser._global_parser is None: - srfsh.report("Loading and parsing IDL...", True, True) - oils.utils.idl.IDLParser.parse() - srfsh.report("OK\n", True, True) - - if args[0] == 'show': - - if args[1] == 'class': - class_ = args[2] - srfsh.report(str(oils.utils.idl.IDLParser.get_class(class_))) - - -def load(srfsh, config): - ''' Srfsh plugin loader ''' - - # load the IDL - if config.get("load_idl", "") == "true": - oils.utils.idl.IDLParser.parse() - - # register custom commands - srfsh.add_command(command = 'login', handler = handle_login) - srfsh.add_command(command = 'auth_verify', handler = handle_auth_verify) - srfsh.add_command(command = 'idl', handler = handle_idl) - srfsh.add_command(command = 'org_setting', handler = handle_org_setting) - - # add some service names to the tab complete word bank - srfsh.tab_complete_words.append('open-ils.auth') - srfsh.tab_complete_words.append('open-ils.cstore') - # TODO: load services for tab-complete from opensrf settings... - diff --git a/Open-ILS/src/python/oils/system.py b/Open-ILS/src/python/oils/system.py deleted file mode 100644 index 132df7c7c3..0000000000 --- a/Open-ILS/src/python/oils/system.py +++ /dev/null @@ -1,44 +0,0 @@ -# ----------------------------------------------------------------------- -# Copyright (C) 2007 Georgia Public Library Service -# Bill Erickson -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# ----------------------------------------------------------------------- - -import osrf.log -import osrf.system -from oils.utils.idl import IDLParser -from oils.utils.csedit import oilsLoadCSEditor - -class System(object): - - @staticmethod - def connect(**kwargs): - """ - Connects to the OpenSRF network, parses the IDL, and loads the CSEditor. - """ - - osrf.system.System.connect(**kwargs) - IDLParser.parse() - oilsLoadCSEditor() - - @staticmethod - def remote_connect(**kwargs): - """ - Connects to the OpenSRF network, parses the IDL, and loads the CSEditor. - - This version of connect does not talk to opensrf.settings, which means - it also does not connect to the OpenSRF cache. - """ - - osrf.system.System.net_connect(**kwargs) - IDLParser.parse() - oilsLoadCSEditor() diff --git a/Open-ILS/src/python/oils/utils/__init__.py b/Open-ILS/src/python/oils/utils/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/Open-ILS/src/python/oils/utils/csedit.py b/Open-ILS/src/python/oils/utils/csedit.py deleted file mode 100644 index 987764266c..0000000000 --- a/Open-ILS/src/python/oils/utils/csedit.py +++ /dev/null @@ -1,275 +0,0 @@ -""" -A Python-friendly wrapper for accessing the Evergreen open-ils.cstore service -""" -# ----------------------------------------------------------------------- -# Copyright (C) 2007 Georgia Public Library Service -# Bill Erickson -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# ----------------------------------------------------------------------- - -from oils.utils.idl import IDLParser -from osrf.const import OSRF_APP_SESSION_CONNECTED -from osrf.log import log_debug, log_info, log_error -from osrf.ses import ClientSession -import oils.const -import re - -ACTIONS = ['create', 'retrieve', 'batch_retrieve', 'update', 'delete', 'search'] - -class CSEditor(object): - """ - Contains generated methods for accessing fieldmapper objects using the - following syntax: - - = .__() - - * = CSEditor class instance - * = - * create - = object to create - = the numeric ID of the newly created object - * retrieve - = numeric ID of the object to retrieve - = object, instance of osrf.net_obj.NetworkObject - * batch_retrieve - = list of numeric ID's - = list of objects, instances of osrf.net_obj.NetworkObject - * update - = object to update - = 1 on success - * delete - = object to delete - = 1 on sucess - * search - = a cstore-compatible search dict. e.g. {"id":1}. - See cstore docs for the full range of search options. - = a list of search results. For standard searches, this - will be a list of objects. idlist searches will return - a list of ID's. - * = the name of the schema that contains the table - *
= the name of the table - - Each generated object has accessor methods corresponding to the fieldmapper - name attributes for a given field. The following example demonstrates how to - instantiate the CSEditor and a given table object, and how to invoke an - accessor method on that table object: - - >>> import oils.utils.csedit - >>> import oils.utils.idl - >>> import osrf.system - >>> osrf.system.connect('/openils/conf/opensrf_core.xml', 'config.opensrf') - >>> oils.utils.idl.oilsParseIDL() - >>> oils.utils.csedit.oilsLoadCSEditor() - >>> editor = oils.utils.csedit.CSEditor() - >>> rec = editor.retrieve_biblio_record_entry(-1) - >>> print rec.tcn_value() - """ - - def __init__(self, **args): - ''' - Creates a new editor object. - - Support keyword arguments: - authtoken - Authtoken string -- used to determine - the requestor if none is provided. - requestor - existing user (au) object. The requestor is - is the user performing the action. This is important - for permission checks, logging, etc. - connect - boolean. If true, a connect call is sent to the opensrf - service at session create time - xact - boolean. If true, a cstore transaction is created at - connect time. xact implies connect. - ''' - - self.app = args.get('app', oils.const.OILS_APP_CSTORE) - self.authtoken = args.get('authtoken', args.get('auth')) - self.requestor = args.get('requestor') - self.connect = args.get('connect') - self.xact = args.get('xact') - self.__session = None - - def die_event(self): - ''' Rolls back the existing transaction, disconnects our session, - and returns the last received event. - ''' - pass - - def checkauth(self): - ''' Checks the authtoken against open-ils.auth and uses the - retrieved user as the requestor - ''' - pass - - # ------------------------------------------------------------------------- - # Creates a session if one does not already exist. If necessary, connects - # to the remote service and starts a transaction - # ------------------------------------------------------------------------- - def session(self, ses=None): - """ - Creates a session if one does not already exist. - - If necessary, connects to the remote service and starts a transaction. - """ - - if not self.__session: - self.__session = ClientSession(self.app) - - if self.connect or self.xact: - self.log(log_debug,'connecting to ' + self.app) - self.__session.connect() - - if self.xact: - self.log(log_info, "starting new db transaction") - self.request(self.app + '.transaction.begin') - - return self.__session - - def log(self, func, string): - ''' Logs string with some meta info ''' - - meta = "editor[" - if self.xact: - meta += "1|" - else: - meta += "0|" - - if self.requestor: - meta += str(self.requestor.id()) - else: - meta += "0" - meta += "]" - func("%s %s" % (meta, string)) - - def rollback(self): - ''' Rolls back the existing db transaction ''' - - if self.__session and self.xact: - self.log(log_info, "rolling back db transaction") - self.request(self.app + '.transaction.rollback') - self.disconnect() - - def commit(self): - ''' Commits the existing db transaction and disconnects ''' - - if self.__session and self.xact: - self.log(log_info, "comitting db transaction") - self.request(self.app + '.transaction.commit') - self.disconnect() - - def disconnect(self): - ''' Disconnects from the remote service ''' - if self.__session: - self.__session.disconnect() - self.__session = None - - def request(self, method, params=[]): - """ - Sends a request. - """ - - # XXX improve param logging here - - self.log(log_info, "request %s %s" % (method, unicode(params))) - - if self.xact and self.session().state != OSRF_APP_SESSION_CONNECTED: - self.log(log_error, "csedit lost its connection!") - - val = None - - try: - req = self.session().request2(method, params) - resp = req.recv() - val = resp.content() - - except Exception, e: - self.log(log_error, "request error: %s" % unicode(e)) - raise e - - return val - - # ------------------------------------------------------------------------- - # Returns true if our requestor is allowed to perform the request action - # 'org' defaults to the requestors ws_ou - # ------------------------------------------------------------------------- - def allowed(self, perm, org=None): - pass # XXX - - def runMethod(self, action, obj_type, arg, options={}): - - method = "%s.direct.%s.%s" % (self.app, obj_type, action) - - if options.get('idlist'): - method = method.replace('search', 'id_list') - del options['idlist'] - - if action == 'search': - method += '.atomic' - - if action == 'batch_retrieve': - method = method.replace('batch_retrieve', 'search') - method += '.atomic' - arg = {'id' : arg} - - params = [arg] - if len(options.keys()): - params.append(options) - - val = self.request( method, params ) - - return val - - def rawSearch(self, args): - method = "%s.json_query.atomic" % self.app - self.log(log_debug, "rawSearch args: %s" % unicode(args)) - return self.request(method, [args]) - - def rawSearch2(self, hint, fields, where, from_=None): - if not from_: - from_ = {'%s' % hint : {}} - - args = { - 'select' : { '%s' % hint : fields }, - 'from' : from_, - 'where' : { "+%s" % hint : where } - } - return self.rawSearch(args) - - def fieldSearch(self, hint, fields, where): - return self.rawSearch2(hint, fields, where) - -__editor_loaded = False -def oilsLoadCSEditor(): - """ - Creates a class method for each action on each type of fieldmapper object - """ - - global __editor_loaded - if __editor_loaded: - return - __editor_loaded = True - - obj = IDLParser.get_parser().idl_object - - for fmap in obj.itervalues(): - for action in ACTIONS: - - fmname = fmap.fieldmapper.replace('::', '_') - obj_type = fmap.fieldmapper.replace('::', '.') - name = "%s_%s" % (action, fmname) - - method = 'def %s(self, arg, **options):\n' % name - method += '\treturn self.runMethod("%s", "%s"' % (action, obj_type) - method += ', arg, dict(options))\n' - method += 'setattr(CSEditor, "%s", %s)' % (name, name) - - exec(method) - diff --git a/Open-ILS/src/python/oils/utils/idl.py b/Open-ILS/src/python/oils/utils/idl.py deleted file mode 100644 index fd6f3e2082..0000000000 --- a/Open-ILS/src/python/oils/utils/idl.py +++ /dev/null @@ -1,288 +0,0 @@ -""" -Parses an Evergreen fieldmapper IDL file and builds a global registry of -objects representing that IDL. - -Typical usage: - ->>> import osrf.system ->>> import oils.utils.idl ->>> osrf.system.connect('/openils/conf/opensrf_core.xml', 'config.opensrf') ->>> oils.utils.idl.IDLParser.parse() ->>> # 'bre' is a network registry hint, or class ID in the IDL file -... print oils.utils.idl.IDLParser.get_class('bre').tablename -biblio.record_entry -""" -import xml.dom.minidom -#import osrf.net_obj, osrf.log, osrf.set, osrf.ex, osrf.ses -import osrf.net_obj, osrf.log, osrf.ex, osrf.ses -from oils.const import OILS_NS_OBJ, OILS_NS_PERSIST, OILS_NS_REPORTER, OILS_APP_ACTOR - -class IDLException(osrf.ex.OSRFException): - """Exception thrown when parsing the IDL file""" - pass - -class IDLParser(object): - """Evergreen fieldmapper IDL file parser""" - - # ------------------------------------------------------------ - # static methods and variables for managing a global parser - # ------------------------------------------------------------ - _global_parser = None - - @staticmethod - def get_parser(): - ''' Returns the global IDL parser object ''' - if IDLParser._global_parser is None: - raise IDLException("IDL has not been parsed") - return IDLParser._global_parser - - @staticmethod - def parse(): - ''' Finds the path to the IDL file from the OpenSRF settings - server, parses the IDL file, and uses the parsed data as - the global IDL repository ''' - if IDLParser._global_parser is None: - parser = IDLParser() - idl_path = osrf.ses.ClientSession.atomic_request( - OILS_APP_ACTOR, 'opensrf.open-ils.fetch_idl.file') - parser.set_idl(idl_path) - parser.parse_idl() - IDLParser._global_parser = parser - - @staticmethod - def get_class(class_name): - ''' Returns the IDLClass object with the given - network hint / IDL class name. - @param The class ID from the IDL - ''' - return IDLParser.get_parser().idl_object[class_name] - - # ------------------------------------------------------------ - # instance methods - # ------------------------------------------------------------ - - def __init__(self): - """Initializes the IDL object""" - self.idl_object = {} - self.idl_file = None - - def set_IDL(self, idlfile): - """Deprecated non-PEP8 version of set_idl()""" - self.set_idl(idlfile) - - def set_idl(self, idlfile): - """Specifies the filename or file that contains the IDL""" - self.idl_file = idlfile - - def parse_IDL(self): - """Deprecated non-PEP8 version of parse_idl()""" - self.parse_idl() - - def parse_idl(self): - """Parses the IDL file and builds class, field, and link objects""" - - # in case we're calling parse_idl directly - if not IDLParser._global_parser: - IDLParser._global_parser = self - - doc = xml.dom.minidom.parse(self.idl_file) - root = doc.documentElement - - for child in root.childNodes: - - if child.nodeType == child.ELEMENT_NODE and child.nodeName == 'class': - - # ----------------------------------------------------------------------- - # 'child' is the main class node for a fieldmapper class. - # It has 'fields' and 'links' nodes as children. - # ----------------------------------------------------------------------- - - obj = IDLClass( - _attr(child, 'id'), - controller = _attr(child, 'controller'), - fieldmapper = _attr(child, 'oils_obj:fieldmapper', OILS_NS_OBJ), - virtual = _attr(child, 'oils_persist:virtual', OILS_NS_PERSIST), - label = _attr(child, 'reporter:label', OILS_NS_REPORTER), - tablename = _attr(child, 'oils_persist:tablename', OILS_NS_PERSIST), - field_safe = _attr(child, 'oils_persist:field_safe', OILS_NS_PERSIST), - ) - - self.idl_object[obj.name] = obj - - fields = [f for f in child.childNodes if f.nodeName == 'fields'] - links = [f for f in child.childNodes if f.nodeName == 'links'] - - fields = _parse_fields(obj, fields[0]) - if len(links) > 0: - _parse_links(obj, links[0]) - - osrf.net_obj.register_hint( - obj.name, [f.name for f in fields], 'array' - ) - - doc.unlink() - - -class IDLClass(object): - """Represents a class in the fieldmapper IDL""" - - def __init__(self, name, **kwargs): - self.name = name - self.controller = kwargs.get('controller') - self.fieldmapper = kwargs.get('fieldmapper') - self.virtual = _to_bool(kwargs.get('virtual')) - self.label = kwargs.get('label') - self.tablename = kwargs.get('tablename') - self.primary = kwargs.get('primary') - self.sequence = kwargs.get('sequence') - self.field_safe = _to_bool(kwargs.get('field_safe')) - self.fields = [] - self.links = [] - self.field_map = {} - - def __str__(self): - ''' Stringify the parsed IDL ''' # TODO: improve the format/content - - idl = '-'*60 + '\n' - idl += "%s [%s] %s\n" % (self.label, self.name, self.tablename) - idl += '-'*60 + '\n' - idx = 0 - for field in self.fields: - idl += "[%d] " % idx - if idx < 10: - idl += " " - idl += str(field) + '\n' - idx += 1 - - return idl - - def get_field(self, field_name): - """Return the specified field from the class""" - - try: - return self.field_map[field_name] - except: - msg = "No field '%s' in IDL class '%s'" % (field_name, self.name) - osrf.log.log_warn(msg) - #raise IDLException(msg) - -class IDLField(object): - """Represents a field in a class in the fieldmapper IDL""" - - def __init__(self, idl_class, **kwargs): - ''' - @param idl_class The IDLClass object which owns this field - ''' - self.idl_class = idl_class - self.name = kwargs.get('name') - self.label = kwargs.get('label') - self.rpt_datatype = kwargs.get('rpt_datatype') - self.rpt_select = kwargs.get('rpt_select') - self.primitive = kwargs.get('primitive') - self.virtual = kwargs.get('virtual') - self.position = kwargs.get('position') - - if self.virtual and str(self.virtual).lower() == 'true': - self.virtual = True - else: - self.virtual = False - - def __str__(self): - ''' Format as field name and data type, plus linked class for links. ''' - field = self.name - if self.rpt_datatype: - field += " [" + self.rpt_datatype - if self.rpt_datatype == 'link': - link = [ - l for l in self.idl_class.links - if l.field.name == self.name - ] - if len(link) > 0 and link[0].class_: - field += " @%s" % link[0].class_ - field += ']' - return field - - -class IDLLink(object): - """Represents a link between objects defined in the IDL""" - - def __init__(self, field, **kwargs): - ''' - @param field The IDLField object this link references - ''' - self.field = field - self.reltype = kwargs.get('reltype') - self.key = kwargs.get('key') - self.map = kwargs.get('map') - self.class_ = kwargs.get('class_') - -def _attr(node, name, namespace=None): - """ Find the attribute value on a given node - Namespace is ignored for now; - not sure if minidom has namespace support. - """ - attr = node.attributes.get(name) - if attr: - return attr.nodeValue - return None - -def _parse_links(idlobj, links): - """Parses the links between objects defined in the IDL""" - - for link in [l for l in links.childNodes if l.nodeName == 'link']: - obj = IDLLink( - field = idlobj.get_field(_attr(link, 'field')), - reltype = _attr(link, 'reltype'), - key = _attr(link, 'key'), - map = _attr(link, 'map'), - class_ = _attr(link, 'class') - ) - idlobj.links.append(obj) - -def _parse_fields(idlobj, fields): - """Takes the fields node and parses the included field elements""" - - idlobj.primary = _attr(fields, 'oils_persist:primary', OILS_NS_PERSIST) - idlobj.sequence = _attr(fields, 'oils_persist:sequence', OILS_NS_PERSIST) - - position = 0 - for field in [l for l in fields.childNodes if l.nodeName == 'field']: - - name = _attr(field, 'name') - - if name in ['isnew', 'ischanged', 'isdeleted']: - continue - - obj = IDLField( - idlobj, - name = name, - position = position, - virtual = _attr(field, 'oils_persist:virtual', OILS_NS_PERSIST), - label = _attr(field, 'reporter:label', OILS_NS_REPORTER), - rpt_datatype = _attr(field, 'reporter:datatype', OILS_NS_REPORTER), - rpt_select = _attr(field, 'reporter:selector', OILS_NS_REPORTER), - primitive = _attr(field, 'oils_persist:primitive', OILS_NS_PERSIST) - ) - - idlobj.fields.append(obj) - idlobj.field_map[obj.name] = obj - position += 1 - - for name in ['isnew', 'ischanged', 'isdeleted']: - obj = IDLField(idlobj, - name = name, - position = position, - virtual = 'true' - ) - idlobj.fields.append(obj) - position += 1 - - return idlobj.fields - -def _to_bool(field): - """Converts a string from the DOM into a boolean value. """ - - if field and str(field).lower() == 'true': - return True - return False - diff --git a/Open-ILS/src/python/oils/utils/utils.py b/Open-ILS/src/python/oils/utils/utils.py deleted file mode 100644 index 367ea991f1..0000000000 --- a/Open-ILS/src/python/oils/utils/utils.py +++ /dev/null @@ -1,83 +0,0 @@ -""" -Grab-bag of general utility functions -""" - -# ----------------------------------------------------------------------- -# Copyright (C) 2007 Georgia Public Library Service -# Bill Erickson -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# ----------------------------------------------------------------------- - -import hashlib -import osrf.log, osrf.ses - -def md5sum(string): - """ - Return an MD5 message digest for a given input string - """ - - md5 = hashlib.md5() - md5.update(string) - return md5.hexdigest() - -def unique(arr): - """ - Unique-ify a list. only works if list items are hashable - """ - - o = {} - for x in arr: - o[x] = 1 - return o.keys() - -def is_db_true(data): - """ - Returns PostgreSQL's definition of "truth" for the supplied data, roughly. - """ - - if not data or data == 'f' or str(data) == '0': - return False - return True - -def login(username, password, login_type=None, workstation=None): - """ - Login to the server and get back an authentication token - - @param username: user name - @param password: password - @param login_type: one of 'opac', 'temp', or 'staff' (default: 'staff') - @param workstation: name of the workstation to associate with this login - - @rtype: string - @return: a string containing an authentication token to pass as - a required parameter of many OpenSRF service calls - """ - - osrf.log.log_info("attempting login with user " + username) - - seed = osrf.ses.ClientSession.atomic_request( - 'open-ils.auth', - 'open-ils.auth.authenticate.init', username) - - # generate the hashed password - password = md5sum(seed + md5sum(password)) - - return osrf.ses.ClientSession.atomic_request( - 'open-ils.auth', - 'open-ils.auth.authenticate.complete', - { 'workstation' : workstation, - 'username' : username, - 'password' : password, - 'type' : login_type - } - ) - diff --git a/Open-ILS/src/python/setup.py b/Open-ILS/src/python/setup.py deleted file mode 100755 index 5659e081f5..0000000000 --- a/Open-ILS/src/python/setup.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -from setuptools import setup - -setup(name='Evergreen', - version='1.4.0', - install_requires='OpenSRF>=1.0', - description='Evergreen Python Modules', - author='Bill Erickson', - author_email='erickson@esilibrary.com', - license='GPL', - url='http://www.open-ils.org/', - packages=['oils', 'oils.utils'], -) diff --git a/Open-ILS/src/support-scripts/brick_ctl.sh b/Open-ILS/src/support-scripts/brick_ctl.sh index 61a3a7ee0d..815ef4cfe0 100755 --- a/Open-ILS/src/support-scripts/brick_ctl.sh +++ b/Open-ILS/src/support-scripts/brick_ctl.sh @@ -185,7 +185,7 @@ function fetch_build { ln -s $NEW_DIR current; } -# This is a per-service action. Currently only support in Perl (and Python). +# This is a per-service action. Currently only supported in Perl. # When other active languages are added, this script will need a language param # to determine which controller script to call. if [ -n "$OPT_SERVICE" ]; then diff --git a/Open-ILS/src/support-scripts/test-scripts/acq_fund.py b/Open-ILS/src/support-scripts/test-scripts/acq_fund.py deleted file mode 100755 index 17f16b5a59..0000000000 --- a/Open-ILS/src/support-scripts/test-scripts/acq_fund.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python -import sys -import oils.system, oils.utils.utils -import osrf.net_obj, osrf.ses - -# --------------------------------------------------------------- -# Usage: python acq_fund_source.py -# --------------------------------------------------------------- - -oils.system.System.connect(config_file='/openils/conf/opensrf_core.xml', config_context='config.opensrf') -auth_info = oils.utils.utils.login(sys.argv[1], sys.argv[2], 'staff', sys.argv[3]) -authtoken = auth_info['payload']['authtoken'] - -ses = osrf.ses.ClientSession('open-ils.acq') -ses.connect() # not required, but faster for batches of request - -# XXX This loop assumes the existence of orgs with IDs 1-6 and a USD currency -ids = [] -for i in range(0,5): - fund_source = osrf.net_obj.NetworkObject.acqfs() - fund_source.name("test-fund_source-%d" % i) - fund_source.owner(i+1) - fund_source.currency_type('USD') - req = ses.request('open-ils.acq.funding_source.create', authtoken, fund_source) - id = req.recv().content() - print 'created fund_source ' + str(id) - ids.append(id) - -req = ses.request('open-ils.acq.funding_source.org.retrieve', authtoken, 1, {"children":1}) -resp = req.recv().content() -for fund_source in resp: - print 'fetched fund_source ' + str(fund_source.name()) - -for i in ids: - req = ses.request('open-ils.acq.funding_source.delete', authtoken, i) - print 'delete returned ' + str(req.recv().content()) - - -ses.disconnect() # only required if a connect() call was made - - diff --git a/build/tools/script_x_check.sh b/build/tools/script_x_check.sh index d1e3a5578a..79d154666d 100755 --- a/build/tools/script_x_check.sh +++ b/build/tools/script_x_check.sh @@ -7,8 +7,7 @@ # or wherever you want to check, inclusive of subdirectories find . \ - \( -path ./Open-ILS/src/python/oils -prune \ - -o -path ./build/i18n/tests/testhelper.py -prune \ + \( -path ./build/i18n/tests/testhelper.py -prune \ -o -path ./Open-ILS/src/extras/Evergreen.py -prune \ \) -o \ \ @@ -25,12 +24,5 @@ exit; ######################################################## These should be exceptions (non-executable python libs): -./Open-ILS/src/python/oils/const.py -./Open-ILS/src/python/oils/event.py -./Open-ILS/src/python/oils/org.py -./Open-ILS/src/python/oils/system.py -./Open-ILS/src/python/oils/utils/utils.py -./Open-ILS/src/python/oils/utils/csedit.py -./Open-ILS/src/python/oils/utils/idl.py ./Open-ILS/src/extras/Evergreen.py ./build/i18n/tests/testhelper.py diff --git a/configure.ac b/configure.ac index d807121082..e0baeb9c74 100644 --- a/configure.ac +++ b/configure.ac @@ -167,19 +167,6 @@ esac], AM_CONDITIONAL([BUILDEGJAVA], [test x$evergreen_java = xtrue]) -# build the evergreen python modules? - -AC_ARG_ENABLE([python], -[ --enable-python enables installation of the Evergreen Python modules ], -[case "${enableval}" in - yes) EG_PYTHON_INSTALL=true ;; - no) EG_PYTHON_INSTALL=false ;; - *) AC_MSG_ERROR([please choose another value for --enable-python (supported values are yes or no)]) -esac], -[EG_PYTHON_INSTALL=false]) - -AM_CONDITIONAL([BUILDEGPYTHON], [test x$EG_PYTHON_INSTALL = xtrue]) - #----------------------------------- # Check for dependencies #----------------------------------- @@ -364,8 +351,7 @@ if test "x$openils_core" = "xtrue"; then Open-ILS/src/c-apps/Makefile Open-ILS/src/c-apps/tests/Makefile Open-ILS/src/extras/Makefile - Open-ILS/src/java/Makefile - Open-ILS/src/python/Makefile]) + Open-ILS/src/java/Makefile]) fi if test "x$build_apachemods" = "xtrue"; then @@ -436,11 +422,6 @@ AC_MSG_RESULT([Evergreen Reporter: no]) AC_MSG_RESULT([Evergreen Staff Client: yes]) else AC_MSG_RESULT([Evergreen Staff Client: no]) - fi - if test "$EG_PYTHON_INSTALL" = "true" ; then -AC_MSG_RESULT([Evergreen Python Components: yes]) - else -AC_MSG_RESULT([Evergreen Python Components: no]) fi if test "$evergreen_java" = "true" ; then AC_MSG_RESULT([Evergreen Java Components: yes]) -- 2.43.2