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)
Пример #2
0
def main():
    name = ShowQueue.init_log()
    ryw_view.print_header_logo()
    
    currSel,queueName = get_curr_sel(name)

    searchSel = get_search_result()
    if not searchSel:
        ryw.give_bad_news(
            'AddSearchAll: failed to load current search result.',
            logging.error)
        DisplaySelection.exit_now(1)

    union_and_write(currSel, searchSel, queueName)
    DisplaySelection.exit_now(0)
Пример #3
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()
Пример #4
0
def main():
    name = ShowQueue.init_log()
    ryw_view.print_header_logo()
    
    searchSel = AddSearchAll.get_search_result()
    if not searchSel:
        ryw.give_bad_news(
            'DelSearchAll: failed to load current search result.',
            logging.error)
        DisplaySelection.exit_now(1)

    success = delete_all(searchSel)
    if success:
        ryw.give_news('All these objects have been removed.', logging.info)
    else:
        ryw.give_bad_news('DelSearchAll.py: an error occurred.',
                          logging.error)
        
    DisplaySelection.exit_now(0)
def get_file_path(searchFile = None, allowNullSearchFile = False):
    success,objID,version = ryw.get_obj_str()
    if not success:
        ryw.give_bad_news('ThisSelToCurrSel: failed to get objstr.',
                          logging.critical)
        return None

    rfpath = DisplaySelection.get_file_path(
        objID, version, searchFile = searchFile,
        allowNullSearchFile = allowNullSearchFile)
    return rfpath
Пример #6
0
def main():
    ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                      'upload.log')
    logging.debug('DisplayObject: entered...')
    ryw_view.print_header_logo()

    print "<TITLE>Displaying an Object</TITLE>"

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

    if do_show(objID, version):
        pass
	#sys.stdout.write("True")
        #ryw.give_good_news('Delete object: apparent success', logging.info)

    DisplaySelection.exit_now(0)
Пример #7
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 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()
Пример #9
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()
Пример #10
0
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)
Пример #11
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()
Пример #12
0
def get_file_path(objID, version, searchFile, repositoryRoot):
    """a helper function.
    a replacement for DisplaySelection.get_file_path,
    faster lookup using the searchFile passed in.
    called by read_container_file."""
    
    sys.path.append(os.path.join(RepositoryRoot, 'cgi-bin'))
    import DisplaySelection

    success,dataPath = get_path(objID, version, searchFile, repositoryRoot)
    if not success:
        return None

    name = DisplaySelection.get_sel_name(dataPath)
    if not name:
        ryw.give_bad_news(
            'ReverseLists.get_file_path: failed to get selection ' +
            'file name:<br>'+ dataPath, logging.error)
        return None

    rfpath = os.path.join(dataPath, name)
    return rfpath
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()
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)
Пример #15
0
def main():

    name = print_header()
    form = cgi.FieldStorage()
    WebUpload_ryw.setup_logging()


    #
    # get objstr.
    #
    success,objID,version = ryw.get_obj_str2(form)
    if not success:
        ryw.give_bad_news('CloneVersion: failed to get objstr.',
                          logging.critical)
        ryw_upload.quick_exit(1)

    message = 'CloneVersion: ' + objID + '#' + str(version)
    logging.info(message)
    ryw.db_print2("<BR>" + message + "<BR>", 23);


    #
    # open search file.
    #
    success,searchFile = ryw.open_search_file(
        'CloneVerson',
        os.path.join(RepositoryRoot, 'WWW', 'logs'),
        'upload.log',
        os.path.join(RepositoryRoot, 'SearchFile'),
        False)
    if not success:
        if searchFile:
            searchFile.done()
        ryw.give_bad_news('CloneVersion: ' +
                          'open search file failed. ',
                          logging.critical)
        ryw_upload.quick_exit(1)
    else:
        ryw.db_print2("search file opened." + "<BR>", 23);


    #
    # get meta and paths.
    #
    success,paths,meta = DisplaySelection.get_all_paths(
        objID, version, skipLock=False, searchFile=searchFile,
        allowNullSearchFile=False)
    if success:
        ryw.db_print_info_browser('CloneVersion: paths: ' + repr(paths), 24)
        ryw.db_print_info_browser('CloneVersion: meta: ' + repr(meta), 29)
    else:
        ryw_upload.quick_exit(1)
        
    if (searchFile):
        searchFile.done()


    #
    # we do want to clone the data if it were a list.
    #
    isList = ryw_meta.isList(meta)
    if isList:
        dataPath = paths[0]
        selName = DisplaySelection.get_sel_name(dataPath)
        if not selName:
            ryw.give_bad_news(
                'CloneVersion: isList but failed to get selection name.',
                logging.error)
            ryw_upload.quick_exit(1)
        selPath = os.path.join(dataPath, selName)
    else:
        selPath,selName = None,None
            

    #
    # change meta.
    #
    meta = change_meta(meta, name)
                                   

    #
    # deal with auxi dir.
    #
    originalAuxiDir = paths[2]
    newAuxiDir = None
    tmpdir = None
    if os.path.exists(originalAuxiDir):
        tmpdir = WebUpload_ryw.attempt_make_tmpdir()
        if not tmpdir:
            ryw_upload.quick_exit(1)
        newAuxiDir = os.path.join(tmpdir, '_AUXI')

        message = 'CloneVersion: shutil.copytree(): ' + \
                  originalAuxiDir + '  ->  ' + newAuxiDir

        try:
            shutil.copytree(originalAuxiDir, newAuxiDir)
        except:
            ryw.give_bad_news('failed: ' + message, logging.critical)
            ryw_upload.cleanup_and_exit(tmpdir, None, None, 1)

        ryw.db_print_info_browser(message, 29)            
                              

    #
    # Now try to put a new object in the repository.
    # note that the version number will be incremented.
    #
    # "selPath" used to be just None.
    # when I added cloning list, I'm just using this to pass in the
    # path name of the selection file.
    #
    if not WebUpload_ryw.try_upload_object(meta, selPath, newAuxiDir,
                                           cloneVersion=True):
        ryw_upload.cleanup_and_exit(tmpdir, None, None, 1)


    searchFile = WebUpload_ryw.show_one_server_object(meta)
    searchFile.done()
        
    ryw_upload.cleanup_and_exit(tmpdir, None, None, 0,
                                successMessage = 'clone version completed.')
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()
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()