Exemplo n.º 1
0
def main():
    name = init_log()
    ryw_view.print_header_logo()
    print '<TITLE>Browsing Selection</TITLE>'

    offsetResult = get_offset()
    success,isAll,offsetNum = offsetResult
    if not success:
        DisplaySelection.exit_now(1)
    
    print_header(name)
    rfpath = os.path.join(RepositoryRoot, 'QUEUES', name)
    reqList = read_list(rfpath)
    if not reqList:
        ryw.give_news('no object selected.', logging.info)
        DisplaySelection.exit_now(0)


    success,searchFile,reverseLists = \
        ReverseLists.open_searchfile_reverselists(
        'ShowQueue.main:')

    if not success:
        DisplaySelection.exit_now(0)

    if go_through_list(reqList, offResult = offsetResult,
                       searchFile = searchFile, reverseLists = reverseLists):
        print_buttons(name)
        
    ryw_view.print_footer()
    searchFile.done()
    reverseLists.done()
def main():
    ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                      'upload.log')
    logging.debug('ThisSelToCurrSel: entered...')
    ryw_view.print_header_logo()

    rfpath = get_file_path(allowNullSearchFile = True)
    if not rfpath:
        ryw.give_bad_news(
            'ThisSelToCurrSel: no selection file name found.',
            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)

    try:
        shutil.copyfile(rfpath, queueName)
    except:
        ryw.give_bad_news('ThisSelToCurrSel: failed to overwrite: ' +
                          rfpath + ' -> ' + queueName,
                          logging.critical)
        DisplaySelection.exit_now(1)

    ryw.give_news(
        'This selection successfully loaded as the current selection.',
        logging.info)
    ryw.give_news('You may want to reload the page containing '+
                  'the affected current selection.', logging.info)
    ryw_view.print_footer()
Exemplo n.º 3
0
def cleanup_and_exit(tmpdir, metafile, extractDir, exitCode,
                     successMessage = 'upload completed.'):
    """wipe out temporary files and directories, and exit."""
    ryw.cleanup_path(tmpdir,     'cleanup_and_exit, tmpdir:')
    ryw.cleanup_path(metafile,   'cleanup_and_exit, metafile:')
    ryw.cleanup_path(extractDir, 'cleanup_and_exit, extractDir:')
    if tmpdir:
        ryw.cleanup_path(tmpdir + '_AUXI', 'cleanup_and_exit, aux dir:')

    if (exitCode == 0):
        ryw.give_good_news(successMessage, logging.info)

    #print '<BR><BR><A HREF="/index.html">back to home</A><br>'
    ryw_view.print_footer()
            
    sys.exit(exitCode)
def main():
    init_log()
    ryw_view.print_header_logo()
    print '<TITLE>Test ReverseLists</TITLE>'

    success,reverseLists = ReverseLists.open_reverse_lists(
        'TestReverseLists:',
        os.path.join(RepositoryRoot, 'WWW', 'logs'),
        'upload.log',
        os.path.join(RepositoryRoot, 'ReverseLists'),
        False,
        allowNullSearchFile = True)
    if success:
        reverseLists.printme()
        reverseLists.done()
    ryw_view.print_footer()
def main():
	ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                      'upload.log')
	 
	logging.debug("outgoing disc queue entered")
	success,resources = get_resources()
	if not success:
		ryw.give_bad_news("main: error parsing resource file",logging.error)
	 
	outdir = resources['tmpout']
	dirlist = os.listdir(outdir)
	if len(dirlist) == 0:
		print "<br><h3>There are no pending outgoing discs waiting to be written\n"
	else:
		generate_table(resources,dirlist)
	
	logging.debug("generated queue page")
	ryw_view.print_footer()
def deleteAll():

	print '<TITLE>Deleting Outing Disc Images</TITLE>'
	ryw_view.print_logo()

	success,resources = get_resources()
	if not success:
		logging.error("main: error parsing resource file")
		sys.exit(1)
	 
	outdir = resources['tmpout']
	for i in [os.path.join(outdir,k) for k in os.listdir(outdir)]:
		ryw.cleanup_path(i,"delete outgoing image:")
	robotsjobdir = resources['robotsjobdir']
	for i in [os.path.join(robotsjobdir,k) for k in os.listdir(robotsjobdir)]:
		if os.path.isfile(i):
			ryw.cleanup_path(i,"delete outgoing image:")
	
	ryw.give_good_news("Successfully deleted all outgoing images",logging.debug)
	ryw_view.print_footer()
Exemplo n.º 7
0
def main():
    ryw.check_logging(os.path.join(RepositoryRoot, "WWW", "logs"), "upload.log")
    logging.info("ClearTmp: entered...")

    ryw_view.print_header_logo()

    try:
        resources = su.parseKeyValueFile(os.path.join(RepositoryRoot, "Resources.txt"))
        resTmpin = resources["tmpin"]
        resTmpOut = resources["tmpout"]
        robotDir = resources["robotsjobdir"]
    except:
        ryw.give_bad_news("failed to parse resource file.", logging.critical)
        sys.exit(1)

    ryw.empty_tmp_dir(resTmpin, chmodFirst=True)
    ryw.empty_tmp_dir(resTmpOut)
    ryw.empty_tmp_dir(robotDir, skipList=["Status", "Log"])

    ryw_view.print_footer()
    sys.exit(0)
Exemplo n.º 8
0
def main():
    ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                      'upload.log')
    logging.debug('ProcessDiscs: entered...')

    success,tmpdir,jobfile,autorunMerge,overWrite = init_vals()
    if not success:
        ryw_upload.quick_exit(1)
    
    logging.debug('ProcessDiscs: tmpdir,jobfile: ' + tmpdir + ' ' + jobfile)
    ryw.give_news('processing incoming disc images located in: ' + tmpdir,
                  logging.info)

    if autorunMerge:
	    process_autorun_merge_request(tmpdir, overwrite = overWrite)
	    sys.exit(0)

    process_finished_copies(tmpdir)
    ryw_upload.cleanup_incoming(tmpdir, jobfile)
    
    ryw_view.print_footer()
    sys.exit(0)
def main():

    dateTimeRand = ryw.date_time_rand()
    searchfile = os.path.join(tmpOutDir, 'NewSearchFile' + dateTimeRand)
    osr = ObjectStoreRoot
    
    #ryw.give_news2('ObjectStore is at: ' + osr + '<BR>', logging.info)
    ryw.give_news2('new SearchFile at: ' + searchfile + '<BR>', logging.info)
    ryw.give_news2('generating... &nbsp;&nbsp;', logging.info)
    
    l = glob.glob(osr + "/?/?/?/?/*_META")
    for filename in l:
        meta = loadMeta(filename)
        append_to_new_search_file(searchfile,meta)

    ryw.give_news2('done.<BR>', logging.info)

    osf = OriginalSearchFile
    ryw.give_news2('comparing against ' + osf + ' ... <BR>', logging.info)
    compareSearchFile(osf, searchfile)

    ryw_view.print_footer()
Exemplo n.º 10
0
def main():
	ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                      'upload.log')
	logging.debug('eraseDisc.py: attempted...')
	robotJobsDir = get_resources()

	ryw_view.print_header_logo()
	
	if not robotJobsDir:
		ryw_upload.quick_exit(1)
	
	if not find_scsi_string_for_eraser(robotJobsDir):
		ryw_upload.quick_exit(1)
		
	count = 100
	filename = write_job_file(count, robotJobsDir)
	if not filename:
		ryw_upload.quick_exit(1)
	
	do_erase(filename, count, robotJobsDir)
	wait_to_end_and_cleanup(filename, count, robotJobsDir)
	
	ryw_view.print_footer()
Exemplo n.º 11
0
def burnAll():

	print '<TITLE>Burning All Outing Disc Images</TITLE>'
	ryw_view.print_logo()

	success,resources = get_resources()
	if not success:
		ryw.give_bad_news("main: error parsing resource file",logging.error)
		sys.exit(1)

	robotPresent = ryw.has_robot(resources)
	
	if not robotPresent:
		ryw.give_bad_news("burning all in one go only works with robot. Resource file indicates robot is not present",logging.info)
		sys.exit(1)
		
	outdir = resources['tmpout']
	robotsjobdir = resources['robotsjobdir']

	for i in [os.path.join(outdir,k) for k in os.listdir(outdir)]:
		submitRobotRequest(i,robotsjobdir)
	
	ryw.give_good_news("Successfully submitted write request to robot for all outgoing images",logging.debug)
	ryw_view.print_footer()
def main():
    init_log()
    ryw_view.print_header_logo()
    print '<TITLE>Rebuild ReverseLists</TITLE>'

    success,newReverseListsFile,objectStoreRoot = decide_path()
    if not success:
        sys.exit(1)

    success,searchFile,reverseLists = \
        ReverseLists.open_searchfile_reverselists(
            'RebuildReverseLists:',
            newReverseListsFileName = newReverseListsFile)
    if not success:
        sys.exit(1)
    else:
        ryw.give_news2('<BR>new ReverseLists generated at: ' +
                       newReverseListsFile + '<BR>', logging.info)

    go_through_object_store(objectStoreRoot, reverseLists)

    if reverseLists:
        reverseLists.done()
    ryw_view.print_footer()
Exemplo n.º 13
0
def main():
    """modeled after ShowQueue.py."""

    name = ShowQueue.init_log()
    ryw_view.print_header_logo()
    print "<TITLE>Prepare for Automated Hindi Translation</TITLE>"

    rfpath = os.path.join(RepositoryRoot, "QUEUES", name)
    reqList = ShowQueue.read_list(rfpath)
    if not reqList:
        ryw.give_news("SelectText.py: no object selected.", logging.info)
        DisplaySelection.exit_now(0)

    success, searchFile, reverseLists = ReverseLists.open_searchfile_reverselists("SelectTexts.main:")

    if not success:
        DisplaySelection.exit_now(0)

    extract_texts(reqList, searchFile)

    ryw.give_news("done.", logging.info)
    ryw_view.print_footer()
    searchFile.done()
    reverseLists.done()
def main():
    """modeled after ChapterListForm.py.
    This is for displaying a form that allows editing the chapter list."""

    name = ShowQueue.init_log()
    ryw_view.print_header_logo()
    print '<TITLE>Processing the Chapter List</TITLE>'

    ryw.db_print2('<BR>ChapterListFormHandle.py: entered... <BR>', 39)

    form = cgi.FieldStorage()

    success,objID,version = ryw.get_obj_str(form = form)
    if not success:
        ryw.give_bad_news('ChapterListFormHandle: failed to get objstr.',
                          logging.critical)
        DisplaySelection.exit_now(1)

    ryw.db_print2('ChapterListFormHandle: objstr is: ' +
                  objID + '#' + str(version), 40)

    chapterList = ChapterList.ChapterList(objID + '#' + str(version))
    success,formEntries = chapterList.process_form(form)
    
    if not success:
        ryw.give_bad_news('ChapterListFormHandle: process_form() failed.',
                          logging.error)
        DisplaySelection.exit_now(1)
    
    success,searchFile,reverseLists = \
        ReverseLists.open_searchfile_reverselists(
        'DisplaySelection.main:')
    if not success:
        DisplaySelection.exit_now(1)

    success = DisplaySelection.print_title(objID, version, name, searchFile)
    if not success:
        DisplaySelection.exit_now(1)

    ryw.db_print2('<BR>ChapterListFormHandle.py entered.<BR>', 41)

    nameTriple = DisplaySelection.get_file_paths2(
        objID, version, searchFile = searchFile)
    if not nameTriple:
        DisplaySelection.exit_now(1)
    rfpath,chapterListPath,chapterListFullName = nameTriple
    if not rfpath:
        DisplaySelection.exit_now(1)

    ryw.db_print2('ChapterListFormHandle: chapter list file is: ' +
                  chapterListFullName, 41)

    reqList = ShowQueue.read_list(rfpath)
    if not reqList:
        ryw.give_news('This selection is empty.<BR>', logging.info)
        print '<BR>'
        print_links(objID, version, name)
        DisplaySelection.exit_now(0)

    ryw.db_print2('ChapterListForm.py: gotten selection list.', 41)

    success = chapterList.initialize_with_meta_list(
        reqList, searchFile, reverseLists)

    if not success:
        ryw.give_bad_news('ChapterListFormHandle: ' +
                          'initialize_with_meta_list failed.',
                          logging.error)
        DisplaySelection.exit_now(1)

    chapterList.compare_form_entries_against_meta()
    if not chapterList.write_file(chapterListFullName):
        ryw.give_bad_news('ChapterListFormHandle: write_file() failed.',
                          logging.error)
        DisplaySelection.exit_now(1)

    ryw.give_news('chapter list saved.', logging.info)
                              
    ryw_view.print_footer()

    reverseLists.done()
    searchFile.done()
Exemplo n.º 15
0
def main(logDir, logFile, searchFile, scriptName, resources = None):
    """main function processing search request."""

    # initialization.
    name = print_header()
    form = cgi.FieldStorage()
    setup_logging(logDir, logFile)

    ## cgi.print_form(form)

    ## parse the form to get: query, sorting information, start_index
    ## to know which subset of matches/results to return,
    ## search_attributes for the next_page_button
    query, sort_tuple, start_index, search_attributes, error_message = \
           parse_form(form)
    if query is None:
	print '<P> ERROR while parsing form and constructing ' + \
              'search query:', error_message
	sys.exit(1)

    ## print '<HR>Query:', query

    ## read index file to get the list of dictionaries:
    ## one dictionary for each version of each object, contains its meta-data

    #
    # used to open search file without read.
    # because Sobti is doing the read by himself below.
    # I have to change this because the SearchFile will be passed
    # onto the ReverseLists module for more later lookups.
    # this makes it necessary to do a real SearchFile open.
    #
    #success,searchFileLock = ryw.open_search_file(
    #    'Search:', logDir, logFile, searchFile, False, skipRead = True)
    success,searchFileLock = ryw.open_search_file(
        'Search:', logDir, logFile, searchFile, False, skipRead = False)
    if not success:
        ryw.give_bad_news('Search: failed to acquire search file lock: ' +
                          searchFile, logging.critical)
        ryw_upload.quick_exit(1)
    #else:
        #
        # mis-named: it's really not a searchFileLock, but searchFile itself.
        #
        #displayObject.set_search_file(searchFileLock)
        

    #
    # this is when Sobti used to do his own read, now replaced by mine.
    #
    #metas, error_message = read_index_file_to_get_metas(searchFile)
    metas = searchFileLock.convert_to_sobti_list()
    if metas is None:
	print '<P> ERROR while reading the index file to get ' + \
              'the meta-data dictionaries:', error_message
        searchFileLock.done()
        ryw_upload.quick_exit(1)

    ## build a list of metas that satisfy the given query
    matches = []
    for meta in metas:
        if not ryw_view.should_show_object(meta, resources):
            continue
	if cnf_match.matches_cnf(meta, query):
            matches.append(meta)
            ryw.db_print2('Search:main() ' + repr(meta), 53)

    num_matches = len(matches)

    ## sort the matches by the given sort tuple
    matches, error_message = sort_matches(matches, sort_tuple)
    if matches is None:
	print '<P> ERROR while sorting matches:', error_message
        searchFileLock.done()
        ryw_upload.quick_exit(1)


    #
    # save all current search results in a file for
    # possible inclusion in the current selection.
    #
    matchAllName = save_matches(matches)
    

    ## Return the start_index..(start_index + N) entries from the top
    if num_matches == 0 or start_index >= num_matches:
	num_items = 0
    else:
	start_index = max(0, start_index)
        assert start_index < num_matches

	end_index = start_index + NUM_OBJECTS_PER_PAGE - 1
	end_index = max(0, end_index)
	end_index = min(num_matches - 1, end_index)

	if not (0 <= start_index <= end_index < num_matches):
            print '<P> ASSERT ERROR: start_index, end_index, ' + \
                  'num_matches', start_index, end_index, num_matches
            searchFileLock.done()
            ryw_upload.quick_exit(1)

	num_items = end_index - start_index + 1

    ## num_items is the number of items that will actually be displayed
    ## num_items <= num_matches
    if num_items == 0:
	print '<P><H3>No objects to display</H3>'
        searchFileLock.done()
        ryw_upload.quick_exit(1)
    else:
	#print '<P><H3>%d objects satisfy the search criteria, ' + \
        #      'displaying %d of them</H3>' % (num_matches, num_items)
        print """
<BR><B><FONT SIZE=2>%d
object(s) satisfy the search criteria.</FONT></B>""" % \
              (num_matches)
        print """
<BR><B><FONT SIZE=2>displaying matches %d - %d.</FONT></B><BR>""" % \
              (start_index + 1, start_index + num_items)

        print_next_page_button1(search_attributes, end_index + 1, scriptName,
                                num_matches)

        shownMatches = []
        
        success,reverseLists = ReverseLists.open_reverse_lists(
            'Search:', '', '',
            os.path.join(RepositoryRoot, 'ReverseLists'), True,
            searchFile = searchFileLock,
            repositoryRoot = RepositoryRoot)
        if not (success and reverseLists):
            ryw.give_bad_news('Search.main: failed to open ReverseLists.',
                              logging.critical)
            if reverseLists:
                reverseLists.done()
            return False

        displayObject = ryw_view.DisplayObject(
            RepositoryRoot, calledByVillageSide = False,
            missingFileFunc=Browse.reqDownloadFunc,
            searchFile = searchFileLock,
            reverseLists = reverseLists)
        
        displayObject.begin_print()
	for i in range(start_index, end_index + 1):
            #display_object(matches[i])
            displayObject.show_an_object_compact(matches[i])
            shownMatches.append(matches[i])
        displayObject.end_print()
        reverseLists.done()

        #
        # save search results on this page in a file for
        # possible inclusion in the current selection.
        #
        matchThisPageName = save_matches(shownMatches)

        print_selection_links(matchAllName, matchThisPageName)
        
    	## Include a next-page button
	print_next_page_button2(search_attributes, end_index + 1, scriptName,
                                num_matches)

    searchFileLock.done()
    ryw_view.print_footer()
Exemplo n.º 16
0
def main():
    """modeled after DisplaySelection.py.
    This is for displaying a form that allows editing the chapter list."""

    name = ShowQueue.init_log()
    ryw_view.print_header_logo()
    print '<TITLE>Edit the Chapter List</TITLE>'

    success,objID,version = ryw.get_obj_str()
    if not success:
        ryw.give_bad_news('ChapterListForm: failed to get objstr.',
                          logging.critical)
        DisplaySelection.exit_now(1)

    success,searchFile,reverseLists = \
        ReverseLists.open_searchfile_reverselists(
        'DisplaySelection.main:')
    if not success:
        DisplaySelection.exit_now(1)

    print '<BR><B>Edit chapter names for this selection:</B><BR><BR>'

    success = DisplaySelection.print_title(objID, version, name, searchFile)
    if not success:
        DisplaySelection.exit_now(1)

    ryw.db_print2('<BR>ChapterListForm.py entered.<BR>', 38)
    
    nameTriple = DisplaySelection.get_file_paths2(
        objID, version, searchFile = searchFile)
    if not nameTriple:
        DisplaySelection.exit_now(1)
    rfpath,chapterListPath,chapterFullName = nameTriple
    if not rfpath:
        DisplaySelection.exit_now(1)

    reqList = ShowQueue.read_list(rfpath)
    if not reqList:
        ryw.give_news('This selection is empty.<BR>', logging.info)
        print '<BR>'
        print_links(objID, version, name)
        DisplaySelection.exit_now(0)

    ryw.db_print2('ChapterListForm.py: gotten selection list.', 38)

    success,chapterList = ChapterList.create_and_initialize(
        objID + '#' + str(version),
        reqList, searchFile, reverseLists,
        chapterFullName)
    if not success:
        ryw.give_bad_news('ChapterList.create_and_initialize failed: ' +
                          objID + '#' + str(version), logging.error)
        DisplaySelection.exit_now(1)

    page = chapterList.make_form_string()
    print page
    
    ryw_view.print_footer()

    reverseLists.done()
    searchFile.done()
Exemplo n.º 17
0
def quick_exit(exitCode):
    ryw_view.print_footer()
    sys.exit(exitCode)
Exemplo n.º 18
0
def main():
    # initialization.
    print_header()
    form = cgi.FieldStorage()
    setup_logging()

    # cgi.print_form(form)

    success,objID,version = ryw.get_obj_str2(form)
    if not success:
        ryw_upload.quick_exit(1)
    logging.debug('EditObject: ' + objID + '#' + str(version))

    if not ryw_meta.check_required_fields(form):
        ryw_upload.quick_exit(1)

    success,meta,objroot = ryw_meta.get_meta2(RepositoryRoot,
                                                  objID, version)
    if not success:
        ryw_upload.quick_exit(1)



    reext = re_extract_or_not(form)
    if reext:
        paths = ryw_meta.get_paths(objroot, objID, version,
                                   meta, RepositoryRoot)
        if not paths:
            ryw.give_bad_news('EditObject: failed to get paths.',
                              logging.critical)
            ryw_upload.quick_exit(1)

        dataPath = paths[0]
        fileName = get_file_name(dataPath)
        if not fileName:
            reext = False



    success = ryw_meta.process_error_fields(form, meta)
    if not success:
        ryw_upload.quick_exit(1)

    ryw_meta.process_fields(form, meta)
    logging.debug('EditObjects: ' + repr(meta))

    meta = ryw_upload.get_change_date_time(meta)

    #ryw.give_news(repr(meta), logging.info)



    if reext:
        re_extract(dataPath, fileName, meta)


    success,searchFile = do_update_metadata(objroot, objID, version, meta)
    if not success:
        ryw_upload.quick_exit(1)


    show_one_server_object(meta, searchFile)
    ryw.give_good_news('edit completed.', logging.info)

    ryw_view.print_footer()

    if searchFile:
        searchFile.done()
    sys.exit(0)
Exemplo n.º 19
0
def main():

    name = ShowQueue.init_log('DisplayVersions')
    ryw_view.print_header_logo()
    print '<TITLE>Display All Versions</TITLE>'

    form = cgi.FieldStorage()
    objID = form.getfirst('objid', '')

    if not objID:
        ryw.give_bad_news(
            'DisplayVersions: no objID given.', logging.error)
        exit_now(1)
    else:
        ryw.db_print_info_browser('DisplayVersions: objID = ' + objID, 32)

    success,searchFile,reverseLists = \
        ReverseLists.open_searchfile_reverselists(
        'DisplaySelection.main:')
    if not success:
        exit_now(1)

    print_title()

    success,allVersions = searchFile.get_all_version_meta(objID)
    if not success:
        ryw.give_bad_news(
            'DisplayVersion: searchFile.get_all_version_meta failed: ' +
            objID, logging.error)
        exit_now(1)    

    numVers = len(allVersions)

    if numVers < 1:
        ryw.give_bad_news(
            'DisplayVersions: no version found.', logging.error)
        exit_now(1)
    
    metaList = allVersions.values()
    ryw.db_print_info_browser('DisplayVersions: ' + repr(metaList), 32)
    metaList = ryw.sortmeta(metaList)

    displayObject = ryw_view.DisplayObject(
        RepositoryRoot,
        calledByVillageSide = False,
        missingFileFunc = Browse.reqDownloadFunc,
        searchFile = searchFile,
        reverseLists = reverseLists)

    print "<BR><B><FONT SIZE=2>Displaying " + str(numVers) + \
          " version(s) of the object.</FONT></B>"

    displayObject.begin_print()
    for meta in metaList:
        displayObject.show_an_object_compact(meta)
    displayObject.end_print()

    ryw_view.print_footer()

    reverseLists.done()
    searchFile.done()
Exemplo n.º 20
0
def exit_now(num):
    ryw_view.print_footer()
    sys.exit(num)
def main():

    name = ShowQueue.init_log()
    ryw_view.print_header_logo()
    print '<TITLE>Browsing Saved Selection</TITLE>'

    success,objID,version = ryw.get_obj_str()
    if not success:
        ryw.give_bad_news('DisplaySelection: failed to get objstr.',
                          logging.critical)
        exit_now(1)

    offsetResult = ShowQueue.get_offset()
    success,isAll,offsetNum = offsetResult
    if not success:
        exit_now(1)

    success,searchFile,reverseLists = \
        ReverseLists.open_searchfile_reverselists(
        'DisplaySelection.main:')
    if not success:
        sys.exit(1)

    success = print_title(objID, version, name, searchFile)
    if not success:
        exit_now(1)

    nameTriple = get_file_paths2(objID, version, searchFile = searchFile)
    if not nameTriple:
        exit_now(1)
    rfpath,chapterListPath,chapterFullName = nameTriple
    if not rfpath:
        exit_now(1)

    reqList = ShowQueue.read_list(rfpath)
    if not reqList:
        ryw.give_news('This selection is empty.<BR>', logging.info)
        print '<BR>'
        print_links(objID, version, name)
        exit_now(0)

    #
    # do this before displaying so that the ReverseLists is
    # properly reflected before we hit the display code.
    #
    result = reverseLists.add(objID + '#' + str(version), reqList)

    #
    # process the chapter list. 10/24/08.
    #
    success,chapterList = ChapterList.create_and_initialize(
        objID + '#' + str(version),
        reqList, searchFile, reverseLists,
        chapterFullName)
    if not success:
        ryw.give_bad_news('ChapterList.create_and_initialize failed: ' +
                          objID + '#' + str(version), logging.error)
        exit_now(1)

    scriptName = '/cgi-bin/DisplaySelection.py?objstr=' + \
                 objID + '%23' + str(version)
    
    success = \
            ShowQueue.go_through_list(reqList,
                                      callBackFunc = delOneSelFunc, 
                                      cBackArg = objID + '#' + str(version),
                                      offResult = offsetResult,
                                      cgiScript = scriptName,
                                      scriptConnectChar = '&',
                                      searchFile = searchFile,
                                      reverseLists = reverseLists,
                                      chapterList = chapterList)

    if success:
        print_links(objID, version, name)
        
    ryw_view.print_footer()

    reverseLists.done()
    searchFile.done()
Exemplo n.º 22
0
ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                  'upload.log')
logging.debug('FlushQueue: entered...')

ryw.print_header()
print '<TITLE>Generating Outgoing Disc</TITLE>'
ryw_view.print_logo()

#print 'Dear <B><I>' + name + ':</I></B>'


form = cgi.FieldStorage()
tmpdir = form.getfirst("tmpdir","")

if tmpdir and not ryw.is_valid_dir(tmpdir, 'FlushQueue'):
    ryw_view.print_footer()
    sys.exit(1)


meta = form.getfirst('meta', '')
metaOnly = meta == 'true' or meta == 'on'
if metaOnly:
    ryw.give_news2('sending metadata only.<BR>', logging.info)


discLimit = form.getfirst('disc_limit', '')
discLimitInt = None
if discLimit:
    try:
        discLimitInt = int(discLimit)
    except:
def main():
    ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                      'upload.log')
    logging.debug('CurrSelToThisSel: 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('CurrSelToThisSel:')
    if not success:
        ryw.give_bad_news('CurrSelToThisSel: ' +
                          '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(
            'CurrSelToThisSel: no selection file name found.',
            logging.error)
        DisplaySelection.exit_now(1)
    oldContainees = ShowQueue.read_list(rfpath)

    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)
    newContainees = ShowQueue.read_list(queueName)

    try:
        shutil.copyfile(queueName, rfpath)
    except:
        ryw.give_bad_news('CurrSelToThisSel: failed to overwrite: ' +
                          queueName + ' -> ' + rfpath,
                          logging.critical)
        DisplaySelection.exit_now(1)

    ryw.give_news(
        'The current selection successfully loaded as this selection.',
        logging.info)
    ryw.give_news('You may want to reload the page containing '+
                  'this selection.', logging.info)

    success = reverseLists.redefine_container(
        objID+'#'+str(version), oldContainees, newContainees)
    if not success:
        ryw.give_bad_news('CurrSelToThisSel: ' +
                          'reverseLists.redefine_container failed.',
                          logging.critical)

    reverseLists.done()
    searchFile.done()
    ryw_view.print_footer()