Ejemplo n.º 1
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)
Ejemplo n.º 2
0
def mainFunc(name, tmpdir="", onlyMeta=False, discLimit=None):

    ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                      'upload.log')
    logging.debug('WriteCD.py: attempted... tmpdir: ' + tmpdir)

    if discLimit:
        ryw.set_disc_limit(discLimit)
        #ryw.give_news2('WriteCD.py: disc size set to: ' +
        #               str(ryw.maxSizeInKB), logging.info)

    success,username,rfpath,reqs = get_pathsFunc(name)
    if not success:
        ryw.give_bad_news('WriteCD failed.', logging.error)
        return

    success,objKB,tmpStoreDir,tmpStoreName = \
        obj_store_size_inKB(tmpdir=tmpdir)
    if not success:
        ryw.give_bad_news('WriteCD failed.', logging.critical)
        ryw.cleanup_path(tmpStoreDir, 'WriteCD.mainFunc:')
        return

    success,reqsize,reqpath,reqList = collect_req_info(reqs, objKB)
    if not success:
        ryw.give_bad_news('WriteCD failed.', logging.error)
        ryw.cleanup_path(tmpStoreDir, 'WriteCD.mainFunc:')
        return

    success,countCDs = make_discs(reqsize, reqpath, username,
                                  objKB, tmpStoreName, reqList,
                                  tmpDirOption=tmpdir,
                                  metaOnly = onlyMeta)
    if not success:
        ryw.give_bad_news('WriteCD failed.', logging.error)
        ryw.cleanup_path(tmpStoreDir, 'WriteCD.mainFunc:')
        return

#    empty_download_queue(rfpath)
    ryw.give_good_news('Apparent success: number of CDs made = '
                       + repr(countCDs), logging.info)
#    ryw.cleanup_path(tmpStoreDir, 'WriteCD.mainFunc:')
    confirm_delete_queue(rfpath)
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()
Ejemplo n.º 4
0
def mainFunc_old(name):
    ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                      'upload.log')
    logging.debug('WriteCD.py: attempted...')

    success,username,rfpath,reqs = get_pathsFunc(name)
    if not success:
        ryw.give_bad_news('WriteCD failed.', logging.error)
        return

    success,objKB,tmpStoreDir,tmpStoreName = obj_store_size_inKB()
    if not success:
        ryw.give_bad_news('WriteCD failed.', logging.critical)
        ryw.cleanup_path(tmpStoreDir, 'WriteCD.mainFunc:')
        return

    success,reqsize,reqpath,reqList = collect_req_info(reqs, objKB)
    if not success:
        ryw.give_bad_news('WriteCD failed.', logging.error)
        ryw.cleanup_path(tmpStoreDir, 'WriteCD.mainFunc:')
        return

    success,countCDs,finishedStuff = make_discs(reqsize, reqpath, username,
                                                objKB, tmpStoreName, reqList)
    if not success:
        ryw.give_bad_news('WriteCD failed.', logging.error)
        ryw.cleanup_path(tmpStoreDir, 'WriteCD.mainFunc:')
        return

#    AddRobotWriteRequest.wait_for_robot(finishedStuff)

#    empty_download_queue(rfpath)
    ryw.give_good_news('Apparent success: number of CDs made = '
                       + repr(countCDs), logging.info)

#    ryw.cleanup_path(tmpStoreDir, 'WriteCD.mainFunc:')
    confirm_delete_queue(rfpath)
    giveQManagementLink()
Ejemplo n.º 5
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()
Ejemplo n.º 6
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)