def edit_single_deliverable(self): id, ok = QtGui.QInputDialog.getText(self, "Type the Deliverable id to Edit", "Enter deliverable id:") if ok: path_decide, ok = QtGui.QInputDialog.getText( self, "Is the reason SGYT, bin def or Trc def files ? type y to confrim n for any other reason", "Is the reason SGYT, bin def or Trc def files ? type y to confrim n for any other reason" ) if path_decide == "y": print "Now showing the deliverable :: " + str(id) self.parent.set_edit_single_deliverable_detail(str(id)) print "Done ..... " elif path_decide == 'n': message = str( "Please enter the reason to change the deliverabe id : " + id) perform = change_log_creation(gui=self, conn_obj=self.db_connection_obj, message=message, type_entry="change", location="deliverables") if perform: print "Now showing the deliverable :: " + str(id) self.parent.set_edit_single_deliverable_detail(str(id)) print "Done ..... " pass
def approve_all_files_on_tape(self, user_name, approval_status): """ get all the segy files written to tape and loop through them to approve them one at a time, prompt for message if the file was approved before :param user_name: user name approving the file :param approval_status: True or false if this function is called :return: none """ dao_list_tape = self.db_connection_obj.sess.query( self.db_connection_obj.SEGY_write).filter( self.db_connection_obj.SEGY_write.segy_w_path == self.segy_w_log_path).all() for tape_write_obj_to_change in dao_list_tape: file_name_dao = self.db_connection_obj.sess.query( self.db_connection_obj.SEGY_QC_on_disk).filter( self.db_connection_obj.SEGY_QC_on_disk.id_seq_segy_qc == tape_write_obj_to_change.id_segy_qc).first() if tape_write_obj_to_change.tape_qc_run_status is None: logger.info("Now Approving SEGY write => Tape Label : " + tape_write_obj_to_change.tape_label + " set_no : " + str(tape_write_obj_to_change.set_number) + ' linename : ' + file_name_dao.line_name) tape_write_obj_to_change.tape_qc_run_status = True tape_write_obj_to_change.tape_qc_status = approval_status tape_write_obj_to_change.tape_checked_by = str(user_name) tape_write_obj_to_change.tape_checked_on = datetime.datetime.now( ).strftime("%I:%M%p on %B %d, %Y") else: logger.warning("Db entry exists for => Tape Label : " + tape_write_obj_to_change.tape_label + " set_no : " + str(tape_write_obj_to_change.set_number) + ' linename : ' + file_name_dao.line_name) message = str("Tape Label : " + tape_write_obj_to_change.tape_label + " set_no : " + str(tape_write_obj_to_change.set_number) + ' linename : ' + file_name_dao.line_name + 'The log was checked before by: ' + tape_write_obj_to_change.tape_checked_by + " on: " + tape_write_obj_to_change.tape_checked_on + ' ,please enter the reason to change') status = change_log_creation(gui=self, conn_obj=self.db_connection_obj, message=message, type_entry='change', location='segy_write') if status: tape_write_obj_to_change.tape_qc_status = approval_status tape_write_obj_to_change.tape_checked_by = str(user_name) tape_write_obj_to_change.tape_checked_on = datetime.datetime.now( ).strftime("%I:%M%p on %B %d, %Y") self.db_connection_obj.sess.commit()
def delete_usb(self): id, ok = QtGui.QInputDialog.getText(self, "Select the USB to delete", "Enter USB id:") if ok: message = str("Please enter the reason to delete the USB id: " + id) perform = change_log_creation(gui=self, conn_obj=self.db_connection_obj,message = message, type_entry="delete",location="usb_list") if perform: print "Now deleting the USB id :: " + str(id) delete_usb_list_obj(self.db_connection_obj, str(id)) print "Done ..... " self.parent.set_usb_summary()
def edit_single_usb(self): id, ok = QtGui.QInputDialog.getText(self, "Select the USB to Edit", "Enter USB id:") if ok: message = str("Please enter the reason to change the USB id: " + id) perform = change_log_creation(gui=self, conn_obj=self.db_connection_obj, message=message, type_entry="change", location="usb_list") if perform: print "Now showing the USB ID :: " + str(id) self.parent.set_edit_usb(str(id)) print "Done ..... " pass
def chk_and_run(self): run_status = True self.create_qc_obj_dict( ) # This creates a dictionary with all the segy_path to be written to tape as key and segy_qc_obj as key self.create_write_object_list( ) # creates two attributes for self 1. a list of all the write obj and list of segy_qc_id in it self.username = self.get_user_name( ) # This username will be used for all the segy write obj entires for segy_qc_id in self.qc_obj_dict.keys(): if segy_qc_id not in self.existing_write_segy_qc_id_list: # create a new write object self.save_as_segy_write_obj(segy_qc_id) else: segy_write_obj = self.existing_write_obj_dict[segy_qc_id] message = str( "The segy file: " + self.qc_obj_dict[segy_qc_id].segy_on_disk_file_path + " was tape was written before on Tape: " + segy_write_obj.tape_label + " by : " + segy_write_obj.tape_written_by + " on : " + segy_write_obj.tape_written_on + ", Please enter the reason to re create.") change_log_status = change_log_creation( gui=self.parent.parent, conn_obj=self.db_connection_obj, message=message, type_entry="change", location='segy_write') if change_log_status: segy_write_obj = self.db_connection_obj.sess.query( self.db_connection_obj.SEGY_write).filter( self.db_connection_obj.SEGY_write.id_segy_qc == segy_qc_id).filter( self.db_connection_obj.SEGY_write.set_number == int(self.parent.set_no)).first() self.username = self.get_user_name() segy_write_obj.tape_written_by = self.username segy_write_obj.tape_written_on = datetime.datetime.now( ).strftime("%I:%M%p on %B %d, %Y") #Set the other attributes to none as this is a new write segy_write_obj.tape_label = self.tape_name segy_write_obj.tape_qc_run_status = None segy_write_obj.tape_sgy_name = None segy_write_obj.tape_qc_status = None segy_write_obj.tape_checked_by = None segy_write_obj.tape_checked_on = None segy_write_obj.segy_w_path = self.log_path self.db_connection_obj.sess.commit() else: run_status = False if run_status == True: self.run()
def browse_trc_def(self): message = str( "Please enter the reason for the change in Trc.def file for the deliverable id : " + self.id) perform = change_log_creation(gui=self, conn_obj=self.db_connection_obj, message=message, type_entry="change", location="deliverables.trc.def") if perform: fname = QtGui.QFileDialog.getOpenFileName(self, 'Open file', 'c:\\') self.deliverable_def['trc_def'].setText(fname) self.show()
def delete_deliverable(self): id, ok = QtGui.QInputDialog.getText( self, "Type the Deliverable id to delete", "Enter deliverable id:") if ok: message = str( "Please enter the reason to delete the deliverabe id : " + id) perform = change_log_creation(gui=self, conn_obj=self.db_connection_obj, message=message, type_entry="delete", location="deliverables") if perform: print "now deleting the deliverable :: " + str(id) delete_deliverable_obj(self.db_connection_obj, str(id)) print "Done ..... " self.parent.set_deliverables_window()
def approve_log(self, user_name, approval_status): if self.tape_write_obj_to_change.tape_qc_run_status is None: self.tape_write_obj_to_change.tape_qc_run_status = True self.tape_write_obj_to_change.tape_qc_status = approval_status self.tape_write_obj_to_change.tape_checked_by = str(user_name) self.tape_write_obj_to_change.tape_checked_on = datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y") else: message = str( 'The log was checked before by: ' + self.tape_write_obj_to_change.tape_checked_by + " on: " + self.tape_write_obj_to_change.tape_checked_on + ' ,please enter the reason to change') status = change_log_creation(gui=self, conn_obj=self.db_connection_obj, message=message, type_entry='change', location='segy_write') if status: self.tape_write_obj_to_change.tape_qc_status = approval_status self.tape_write_obj_to_change.tape_checked_by = str(user_name) self.tape_write_obj_to_change.tape_checked_on = datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y") self.db_connection_obj.sess.commit() if approval_status: if (self.deliverable.type, self.deliverable.media) in SEGY_write_to_media_table_list: # only if the media entry needs to be created from here self.check_and_create_media_list_entry()
def reel_no_check(self, tape): # This function checks the reel no of all segy selected against reel no entered by the user # and issues a warning if the reel no does not match status = True bad_reel_no_dict = {} for a_file in self.segy_to_write_list: sgyt_reel_no = self.parent.tape_operation_manager.service_class.approved_obj_dict[ a_file].sgyt_reel_no if str(sgyt_reel_no) != str(tape): status = False bad_reel_no_dict.update({a_file: sgyt_reel_no}) if status == False: message_for_pop_up = self.create_message_string_from_incorrect_reel( bad_reel_no_dict, tape) overwrite_status = change_log_creation( gui=self, conn_obj=self.parent.tape_operation_manager.db_connection_obj, message=message_for_pop_up, type_entry='change', location='segy_write') return overwrite_status else: return True
def approve_log(self, user_name, approval_status): tape_write_obj_to_change = self.db_connection_obj.sess.query( self.db_connection_obj.SEGY_write).filter( self.db_connection_obj.SEGY_write.segy_w_path == self.segy_w_log_path).filter( self.db_connection_obj.SEGY_write.id_segy_qc == self.id_segy_qc).first() if tape_write_obj_to_change.tape_qc_run_status is None: tape_write_obj_to_change.tape_qc_run_status = True tape_write_obj_to_change.tape_qc_status = approval_status tape_write_obj_to_change.tape_checked_by = str(user_name) tape_write_obj_to_change.tape_checked_on = datetime.datetime.now( ).strftime("%I:%M%p on %B %d, %Y") else: file_name_dao = self.db_connection_obj.sess.query( self.db_connection_obj.SEGY_QC_on_disk).filter( self.db_connection_obj.SEGY_QC_on_disk.id_seq_segy_qc == tape_write_obj_to_change.id_segy_qc).first() message = str("Tape Label : " + tape_write_obj_to_change.tape_label + " set_no : " + str(tape_write_obj_to_change.set_number) + ' linename : ' + file_name_dao.line_name + 'The log was checked before by: ' + tape_write_obj_to_change.tape_checked_by + " on: " + tape_write_obj_to_change.tape_checked_on + ' ,please enter the reason to change') status = change_log_creation(gui=self, conn_obj=self.db_connection_obj, message=message, type_entry='change', location='segy_write') if status: self.tape_write_obj_to_change.tape_qc_status = approval_status self.tape_write_obj_to_change.tape_checked_by = str(user_name) self.tape_write_obj_to_change.tape_checked_on = datetime.datetime.now( ).strftime("%I:%M%p on %B %d, %Y") self.db_connection_obj.sess.commit()
def create_SEGY_3D_sgyt(self): result = self.db_connection_obj.sess.query( self.db_connection_obj.SEGY_QC_on_disk).filter( self.db_connection_obj.SEGY_QC_on_disk.deliverable_id == self.Deliverable.id).first( ) # This time we do not need a sequence in the filter mocde if result is None: sgyt_file_name = create_3D_sgyt(self.Deliverable, self.IL_range, self.XL_range, int(self.reel)) user_file_name = "user_" + sgyt_file_name # SFTP the template to the DUG workstation # 1. check if the file already exists on the DUG workstation self.dir_service.set_deliverable(self.Deliverable) dir_for_checking = self.dir_service.data_dir_path_dict['masters'] local_path = os.path.join(os.getcwd(), 'temp', sgyt_file_name) remote_path = posixpath.join(dir_for_checking, sgyt_file_name) status = check_generic_path(self.DUG_connection_obj, remote_path) logger.info( "Now attempting to transfer the file to the DUG workstation..." ) if status == 'True': action = get_item_through_dialogue( self.parent, 'Now attempting to transfer the file to the DUG workstation... type y to continue, n to exit' ) if action == 'y': SFTP_generic_file(self.DUG_connection_obj, local_path, remote_path) else: logger.warning('Aborting the file transfer!!!!') else: SFTP_generic_file(self.DUG_connection_obj, local_path, remote_path) # now create a new DAO object new_obj = self.db_connection_obj.SEGY_QC_on_disk() new_obj.line_name = '3D deliverable' new_obj.deliverable_id = self.Deliverable.id new_obj.sgyt_status = True new_obj.sgyt_reel_no = self.Deliverable.reel_prefix + str( self.reel) new_obj.sgyt_min_il = self.IL_range[0] new_obj.sgyt_max_il = self.IL_range[1] new_obj.sgyt_min_xl = self.XL_range[0] new_obj.sgyt_max_xl = self.XL_range[1] new_obj.sgyt_fgsp = None new_obj.sgyt_lgsp = None new_obj.sgyt_min_ffid = None new_obj.sgyt_max_ffid = None new_obj.sgyt_user_path = posixpath.join(dir_for_checking, user_file_name) new_obj.sgyt_unix_path = remote_path new_obj.sgyt_exp_uname = self.username new_obj.sgyt_time_stamp = datetime.datetime.now().strftime( "%I:%M%p on %B %d, %Y") self.db_connection_obj.sess.add(new_obj) self.db_connection_obj.sess.commit() logger.info( "The new object for SEGY on disk QC SEGY template export is now added to the database..." ) else: message = str("The SGYT file for deliverable_id : " + str(self.Deliverable.id) + ": name : " + self.Deliverable.name + " was exported by : " + result.sgyt_exp_uname + ' on : ' + result.sgyt_time_stamp + " Enter reason to re-export: ") perform = change_log_creation(gui=self.parent, conn_obj=self.db_connection_obj, message=message, type_entry="change", location='sgyt') if perform: sgyt_file_name = create_3D_sgyt(self.Deliverable, self.IL_range, self.XL_range, self.reel) user_file_name = "user_" + sgyt_file_name # SFTP the template to the DUG workstation # 1. check if the file already exists on the DUG workstation self.dir_service.set_deliverable(self.Deliverable) dir_for_checking = self.dir_service.data_dir_path_dict[ 'masters'] local_path = os.path.join(os.getcwd(), 'temp', sgyt_file_name) remote_path = posixpath.join(dir_for_checking, sgyt_file_name) status = check_generic_path(self.DUG_connection_obj, remote_path) logger.info( "Now attempting to transfer the file to the DUG workstation..." ) if status == 'True': message = "File already exists on DUG system, type y to continue, n to exit" action = get_item_through_dialogue(self.parent, message) if action == 'y': SFTP_generic_file(self.DUG_connection_obj, local_path, remote_path) else: logger.warning('Aborting the file transfer!!!!') else: SFTP_generic_file(self.DUG_connection_obj, local_path, remote_path) print "File transfer complete .. " # now create a new DAO object result.sgyt_reel_no = self.Deliverable.reel_prefix + str( self.reel) result.sgyt_fgsp = None result.sgyt_lgsp = None result.sgyt_min_ffid = None result.sgyt_max_ffid = None result.sgyt_min_il = self.IL_range[0] result.sgyt_max_il = self.IL_range[1] result.sgyt_min_xl = self.XL_range[0] result.sgyt_max_xl = self.XL_range[1] result.sgyt_user_path = posixpath.join(dir_for_checking, user_file_name) result.sgyt_unix_path = remote_path result.sgyt_exp_uname = self.username result.sgyt_time_stamp = datetime.datetime.now().strftime( "%I:%M%p on %B %d, %Y") if result.sgyt_approval_status is not None: # this step clears the previous status flag as this is a new file and should be checked again result.sgyt_approval_status = None result.sgyt_approver_name = None result.sgyt_approval_time = None self.db_connection_obj.sess.commit()