Exemplo n.º 1
0
	def __running_cb  ( self, p_command ):
	#----------------------------------------------------------------------

		l_string = self.__command_string(p_command)

		if l_string:
			logging.message("Running command: " + l_string)
Exemplo n.º 2
0
	def __aborted_cb  ( self, p_command ):
	#----------------------------------------------------------------------

		l_string = self.__command_string(p_command)

		if l_string:
			logging.message("Aborting command: " + l_string)

		l_journal_entry = self.__journal_entry(p_command)

		if l_journal_entry:
			l_journal_entry.unlock()
Exemplo n.º 3
0
	def __timeout_cb  ( self, p_command ):
	#----------------------------------------------------------------------

		l_string = self.__command_string(p_command)

		if l_string:
			logging.message("Command timeout: " + l_string)

		l_journal_entry = self.__journal_entry(p_command)

		if l_journal_entry:
			l_journal_entry.unlock()

		return False
Exemplo n.º 4
0
def MESSAGE(msg):
    ''' 
    Function which offers user message and integration in log file

    Paramerters
    -----------
    msg : (str) user message, similar to print input
    
    '''
    module_logger = logging.getLogger("pyfetra")
    logging.MESSAGE = 25
    logging.addLevelName(logging.MESSAGE, 'MESSAGE')
    logging.message = lambda msg, *args: module_logger._log(
        logging.MESSAGE, msg, args)
    logging.message(msg)
Exemplo n.º 5
0
	def create ( cls, p_master_path, p_slave_path ):
	#----------------------------------------------------------------------

		l_root_path = cls.find_project_root(p_master_path)

		if l_root_path:
			logging.message("A project already exists, opening " + l_root_path)
			return cls.open(p_master_path)

		l_master_path = os.path.abspath(p_master_path)

		l_config = configuration.Configuration.get_instance()

		if not l_config.load(l_master_path):
			return None

		l_project_dir  = l_config.get_option_value('general', 'project_dir')
		l_project_path = os.path.join(l_master_path, l_project_dir)
		l_cache_path   = os.path.join(l_project_path, 'cache')

		if not os.path.exists(l_project_path):
			try:
				os.makedirs(l_project_path)
			except:
				logging.error("Can't create directory: ", l_project_path)
				return None

		if not os.path.exists(l_cache_path):
			try:
				os.makedirs(l_cache_path)
			except:
				logging.error("Can't create directory: ", l_cache_path)
				return None

		if not l_config.set_option_value(configuration.LEVEL_PROJECT, 'project',
											'slave_path', p_slave_path):
			return None

		if not l_config.save(l_master_path):
			return None

		return cls(l_master_path, p_slave_path)
Exemplo n.º 6
0
	def open ( cls, p_master_path ):
	#----------------------------------------------------------------------

		l_master_path = cls.find_project_root(p_master_path)

		if not l_master_path:
			return None

		logging.message("Project found in " + l_master_path)

		l_config = configuration.Configuration.get_instance()

		if not l_config.load(l_master_path):
			return None

		l_slave_path = l_config.get_option_value('project', 'slave_path')

		if l_slave_path == None:
			return None

		return cls(l_master_path, l_slave_path)
Exemplo n.º 7
0
	def abort ( self ):
	#----------------------------------------------------------------------

		logging.message("Aborting command queue")

		l_running = self.m_running
		l_queue   = self.m_queue[:]

		self.m_running = None
		self.m_queue   = []

		if l_running:
			l_running.m_state = command.ABORTED
			l_running.aborted_cb()

		for l_command in l_queue:
			l_command.m_state = command.ABORTED
			l_command.aborted_cb()

		self.m_buffer = ''
		self.m_state  = self.STATE_IDLE
Exemplo n.º 8
0
	def save ( self, p_project_path = '' ):
	#----------------------------------------------------------------------

		if self.m_site_filename:
			logging.message('Saving site configuration to ' + self.m_site_filename)
			if not self.__save_configuration(LEVEL_SITE, self.m_site_filename):
				return False

		if self.m_user_filename:
			logging.message('Saving user configuration to ' + self.m_user_filename)
			if not self.__save_configuration(LEVEL_USER, self.m_user_filename):
				return False

		if p_project_path:
			l_filename = self.__find_project_configuration(p_project_path)
			logging.message('Saving project configuration to ' + l_filename)
			if not self.__save_configuration(LEVEL_PROJECT, l_filename):
				return False

		return True
Exemplo n.º 9
0
	def load ( self, p_project_path = '' ):
	#----------------------------------------------------------------------

		self.m_sections = {}

		if self.m_site_filename:
			logging.message('Loading site configuration from ' + self.m_site_filename)
			if not self.__load_configuration(LEVEL_SITE, self.m_site_filename):
				return False

		if self.m_user_filename:
			logging.message('Loading user configuration from ' + self.m_user_filename)
			if not self.__load_configuration(LEVEL_USER, self.m_user_filename):
				return False

		if p_project_path:
			l_filename = self.__find_project_configuration(p_project_path)
			if os.path.exists(l_filename):
				logging.message('Loading project configuration from ' + l_filename)
				if not self.__load_configuration(LEVEL_PROJECT, l_filename):
					return False

		return True
Exemplo n.º 10
0
	def __post_error ( self, p_command ):
	#----------------------------------------------------------------------

		l_string = self.__command_string(p_command)

		if l_string:
			logging.message("Command failed: " + l_string)

		l_string = self.__result_string(p_command.get_result())

		if l_string:
			logging.message('\t' + l_string)

		if p_command.get_result().get_opcode() == opcodes.DATA_ERROR:
			logging.message("Retrying...")
			p_command.cleanup()
			return command_queue.CommandQueue.get_instance().insert(p_command)

		l_journal_entry = self.__journal_entry(p_command)

		if l_journal_entry:
			l_journal_entry.unlock()

		return False