def main(): ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'), 'upload.log') logging.debug('ThisSelAddedToCurrSel: entered...') ryw_view.print_header_logo() rfpath = ThisSelToCurrSel.get_file_path(allowNullSearchFile=True) if not rfpath: ryw.give_bad_news( 'ThisSelAddedToCurrSel: no selection file name found.', logging.error) DisplaySelection.exit_now(1) savedSel = ProcessDownloadReq.get_reqs(rfpath) if (not savedSel) or (len(savedSel) == 0): ryw.give_news('ThisSelAddedToCurrSel: this selection is empty.', logging.error) DisplaySelection.exit_now(1) queueName = DeleteRepReq.get_queue_name() if not queueName: ryw.give_bad_news( 'ThisSelToCurrSel: failed to get current selection file name.', logging.error) DisplaySelection.exit_now(1) queueSel = ProcessDownloadReq.get_reqs(queueName) AddSearchAll.union_and_write(queueSel, savedSel, queueName) ryw.give_news('You may want to reload the page containing '+ 'the affected current selection.', logging.info) DisplaySelection.exit_now(0)
def save_matches(matches): if matches == None or len(matches) == 0: ryw.give_news('save_matches: no match to save', logging.warning) return None success,tmpDir,selName = get_save_search_name() if not success: ryw.give_bad_news( 'save_matches: failed to determine selection file name', logging.error) return None selList = make_selection_list(matches) # # copied from ProcessDownloadReq.py # success,tmppath,bakpath = ProcessDownloadReq.write_reqs( os.path.join(tmpDir, selName), set(selList)) ProcessDownloadReq.cleanup(tmppath, bakpath) if not success: ryw.give_bad_news( 'save_matches: ProcessDownloadReq.write_reqs failed: ' + os.path.join(tmpDir, selName), logging.error) return None cleanup_old_search_results(tmpDir, selName) return selName
def main(): ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'), 'upload.log') logging.debug('DeleteRepReq: entered...') queueName = get_queue_name() if not queueName: sys.exit(1) ProcessDownloadReq.delete_request(queueName)
def main(): ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'), 'upload.log') logging.debug('CurrSelAddedToThisSel: entered...') ryw_view.print_header_logo() success,objID,version = ryw.get_obj_str() if not success: ryw.give_bad_news('CurrSelToThisSel: failed to get objstr.', logging.critical) DisplaySelection.exit_now(1) success,searchFile,reverseLists = \ ReverseLists.open_searchfile_reverselists('CurrSelAddedToThisSel:') if not success: ryw.give_bad_news('CurrSelAddedToThisSel: ' + 'open_searchfile_reverselists failed.', logging.critical) DisplaySelection.exit_now(1) rfpath = DisplaySelection.get_file_path( objID, version, searchFile = searchFile) if not rfpath: ryw.give_bad_news( 'CurrSelAddedToThisSel: no selection file name found.', logging.error) DisplaySelection.exit_now(1) queueName = DeleteRepReq.get_queue_name() if not queueName: ryw.give_bad_news( 'CurrSelToThisSel: failed to get current selection file name.', logging.error) DisplaySelection.exit_now(1) queueSel = ProcessDownloadReq.get_reqs(queueName) savedSel = ProcessDownloadReq.get_reqs(rfpath) newContainees = list(queueSel) AddSearchAll.union_and_write(savedSel, queueSel, rfpath) ryw.give_news('You may want to reload the page containing '+ 'this selection.', logging.info) success = reverseLists.add(objID+'#'+str(version), newContainees) if not success: ryw.give_bad_news('CurrSelAddedToThisSel: reverseLists.add failed.', logging.critical) reverseLists.done() searchFile.done() DisplaySelection.exit_now(0)
def main(): ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'), 'upload.log') logging.debug('DeleteFromSel: entered...') ProcessDownloadReq.print_header() #ProcessDownloadReq.delete_request(queue) form = cgi.FieldStorage() if (not form.has_key('objstr')) or (not form.has_key('selobj')): ryw.give_bad_news('DeleteFromSel.py: lacking arguments.', logging.critical) DisplaySelection.exit_now(1) objstr = form.getfirst('objstr', '') selobj = form.getfirst('selobj', '') if (not objstr) or (not selobj): ryw.give_bad_news('DeleteFromSel.py: null arguments.', logging.critical) DisplaySelection.exit_now(1) #ryw.give_news('DeleteFromSel.py: ' + objstr, logging.info) #ryw.give_news('DeleteFromSel.py: ' + selobj, logging.info) success,searchFile,reverseLists = \ ReverseLists.open_searchfile_reverselists('DeleteFromSel:') if not success: ryw.give_bad_news( 'DeleteFromSel: open_searchfile_reverselists failed.', logging.critical) DisplaySelection.exit_now(1) objID,version = selobj.split('#') version = int(version) rfpath = DisplaySelection.get_file_path(objID, version, searchFile=searchFile) if not rfpath: DisplaySelection.exit_now(1) success = ProcessDownloadReq.do_delete(rfpath, objstr) if success: sys.stdout.write("True") else: print "Failed to delete from selection." reverseLists.remove_obsolete_containers(objstr, [selobj]) reverseLists.done()
def main(): name = ShowQueue.init_log() ryw_view.print_header_logo() queueName = DeleteRepReq.get_queue_name() if not queueName: ryw.give_bad_news( 'DelQueueData.py: failed to get current selection file name.', logging.error) DisplaySelection.exit_now(1) queueSel = ProcessDownloadReq.get_reqs(queueName) if not queueSel or len(queueSel) == 0: ryw.give_bad_news( 'DelQueueData.py: there is nothing in the selection.', logging.error) DisplaySelection.exit_now(1) success = DelSearchAll.delete_all(queueSel) if success: ryw.give_news('All these objects have been removed.', logging.info) else: ryw.give_bad_news('DelQueueData.py: an error occurred.', logging.error) DisplaySelection.exit_now(0)
def main(): ryw.check_logging(os.path.join(RepositoryRoot, "WWW", "logs"), "upload.log") logging.debug("SelectAll: entered...") ryw_view.print_header_logo() name = os.getenv("REMOTE_USER") if name == "" or name == None: ryw.give_bad_news("SelectAll: no user name given", logging.error) ryw_upload.quick_exit(1) queue = os.path.join(RepositoryRoot, "QUEUES", name) try: resources = su.parseKeyValueFile(os.path.join(RepositoryRoot, "Resources.txt")) searchFileName = resources["searchfile"] except: ryw.give_bad_news("SelectAll: failed to get search file name from resources.", logging.critical) ryw_upload.quick_exit(1) success, searchFile = ryw.open_search_file( "SelectAll:", os.path.join(RepositoryRoot, "WWW", "logs"), "upload.log", searchFileName, False ) if not success: ryw.give_bad_news("SelectAll: failed to open search file.", logging.critical) ryw_upload.quick_exit(1) if not ProcessDownloadReq.add_all(queue, searchFile): ryw.give_bad_news("selectall: addAll failed.", logging.critical) ryw_upload.quick_exit(1) searchFile.done() ryw_upload.quick_exit(0)
def main(): name = ShowQueue.init_log() ryw_view.print_header_logo() rfpath = ThisSelToCurrSel.get_file_path(allowNullSearchFile=True) if not rfpath: ryw.give_bad_news( 'DelSelData.py: no selection file name found.', logging.error) DisplaySelection.exit_now(1) selection = ProcessDownloadReq.get_reqs(rfpath) if not selection or len(selection) == 0: ryw.give_bad_news( 'DelSelData.py: there is nothing in the selection.', logging.error) DisplaySelection.exit_now(1) success = DelSearchAll.delete_all(selection) if success: ryw.give_news('All these objects have been removed.', logging.info) else: ryw.give_bad_news('DelSelData.py: an error occurred.', logging.error) DisplaySelection.exit_now(0)
def union_and_write(currSel, searchSel, queueName): unionResults = currSel | searchSel # # copied from ProcessDownloadReq.py # success,tmppath,bakpath = ProcessDownloadReq.write_reqs( queueName, unionResults) ProcessDownloadReq.cleanup(tmppath, bakpath) if success: numResults = len(searchSel) ryw.give_news(str(numResults) + ' objects added to the chosen selection.', logging.info) else: ryw.give_bad_news('union_and_write: failed.', logging.error)
def get_search_result(): form = cgi.FieldStorage() selName = form.getfirst('sel', '') if not selName: ryw.give_bad_news( 'AddSearchAll: failed to find current search result: ', logging.error) return None tmpSearchResultDir = Search.decide_search_result_dir() if not tmpSearchResultDir: ryw.give_bad_news('AddSearchAll: ' + 'decide_search_result_dir failed.', logging.error) return None searchFileName = os.path.join(tmpSearchResultDir, selName) searchSel = ProcessDownloadReq.get_reqs(searchFileName) return searchSel
import ProcessDownloadReq import cgi, cgitb, os cgitb.enable() #resources = ParseResources.parseResources() name = os.getenv("REMOTE_USER") if name == "" or name == None: print "Unknown REMOTE_USER. Need to know who is requesting download" else: logDir = os.path.join(RepositoryRoot,'WWW','logs') logFile = 'upload.log' queue = os.path.join(RepositoryRoot,'QUEUES',name) ProcessDownloadReq.main(queue,logDir,logFile)
def get_curr_sel(name): queueName = os.path.join(RepositoryRoot,'QUEUES',name) currSel = ProcessDownloadReq.get_reqs(queueName) return (currSel, queueName)