def import_ids_txt(): global targetids targetids=[] targetids_obj=open("%s/IDs.txt"%cm.active_dir,'r') targetids_raw=targetids_obj.readlines() targetids_obj.close() # TO-DO: check if targetids are possibly invalid and if so, show a warning. for x_raw in targetids_raw: if x_raw[-1:] is """ """: x=x_raw[0:-1] targetids.append(x) else: targetids.append(x_raw) rem_dect="" if cm.active_dir == cm.resume_dir: print "Resuming from previous session..." rem_dect=" remaining" cm.empty_file("%s/IDs.txt"%cm.active_dir) num_targetids=len(targetids) if num_targetids is 1: print "%d%s ID detected.\n"%(num_targetids,rem_dect) else: print "%d%s IDs detected.\n"%(num_targetids,rem_dect) fbio.workingids=targetids[:]
def io_exception(obj_id): global workingids fbauth.check_auth() print "An error occured. If it's a not an authentication error, please check your IDs and connection!" cm.empty_file("%s/IDs.txt"%cm.resume_dir) resume_ids_obj=open("%s/IDs.txt"%cm.resume_dir,'a') for bak in workingids: resume_ids_obj.write("%s\n"%bak) resume_ids_obj.close() print "Current progress has been saved; restart the program to resume." cm.exexc(str(sys.exc_info()[0]),None)
def resume_chk(): resumecheck_obj=open("%s/IDs.txt"%cm.resume_dir,'r') resumecheck=resumecheck_obj.read() resumecheck_obj.close() if resumecheck == '': cm.active_dir = cm.work_dir else: print "Data from last session was found. Resume session?\nType Y to continue, or anything else to discard and start a new session." choice=str(cm.raw_input_lb("> ")).lower().find("y") if choice != -1: print "Resuming..." cm.active_dir = cm.resume_dir else: print "Resume canceled." cm.active_dir = cm.work_dir cm.empty_file("%s/IDs.txt"%cm.resume_dir)