Exemplo n.º 1
0
def handle_exception(module_name,exception_name,*args) :
	
	arduino = ['arduino not responding','cant connect']
	dynamixel = ['dynamixel not responding','cant connect']
	lookup = []
	status_packet_handling  = ['input voltage error','angle limit error',\
	'overheting error','range error','checksum error','overload error',\
	'instruction error','invalid error byte']
	py_main = []

	module_names = {
		'arduino' : arduino,
		'dynamixel' : dynamixel,
		'lookup' : lookup,
		'status_packet_handling' : status_packet_handling,
		'py_main' : py_main,
	}

	if module_name in module_names.keys() and\
		exception_name in module_names[module_name] :
		
		gui.EXCEPTION_MODULE = module_name
		gui.EXCEPTION = exception_name
		error_logging.log(module_name + ':' + exception_name)
		gui.exception_caught(*args)
		gui.some_file.n = int(args[0])
		
	else : 
		print('invalid exception')
		print()
Exemplo n.º 2
0
def handle_exception(module_name,exception_name,*args) :
	
	arduino = ['arduino not responding','cant connect']
	dynamixel = ['dynamixel not responding','cant connect']
	lookup = []
	status_packet_handling  = ['input voltage error','angle limit error',\
	'overheting error','range error','checksum error','overload error',\
	'instruction error','invalid error byte']
	py_main = []

	module_names = {
		'arduino' : arduino,
		'dynamixel' : dynamixel,
		'lookup' : lookup,
		'status_packet_handling' : status_packet_handling,
		'py_main' : py_main,
	}

	module_name = module_name.split('.')[-1]

	if module_name in module_names.keys() and\
		exception_name in module_names[module_name] :
		print('Exception : ' + module_name + '--> ' + exception_name)
		error_logging.log(module_name + '--> ' + exception_name)
		# CHANGE -- Implement functions in GUI and call from here
		if(module_name == 'dynamixel' and exception_name == 'cant connect'):
			dynamixel_not_connected()
	else : 
		print('invalid exception')
Exemplo n.º 3
0
    def add_to_library_from_label(self, label, doi, index=None, referencing_paper=None, popups=True):
        """
        Adds reference paper to library from right-clicking on a label.

        Parameters
        ----------
        label : ReferenceLabel
            The label that was clicked.
        doi : str
            DOI of the paper in the clicked label.
        popups : bool
            If False, suppresses warning pop-up windows.
        """
        # Check that there is a DOI
        if doi is None:
            if popups:
                QMessageBox.warning(self, 'Warning', 'No DOI found for this reference')
            return

        # Check that the paper isn't already in the user's library
        if self._check_lib(doi):
            if popups:
                QMessageBox.information(self, 'Information', 'Paper is already in library.')
            return

        # Try to add, have separate windows for each possible error
        try:
            self.library.add_to_library(doi)
        except UnsupportedPublisherError as exc:
            log(method='gui.Window.add_to_library_from_label', message='Publisher unsupported', error=str(exc), doi=doi,
                ref_index=index, main_lookup=referencing_paper)
            if popups:
                QMessageBox.warning(self, 'Warning', 'Publisher is not yet supported.\n'
                                    'Document not added.')
            return
        except CallFailedException as call:
            log(method='gui.Window.add_to_library_from_label', message='Call failed', error=str(call), doi=doi,
                ref_index=index, main_lookup=referencing_paper)
            if popups:
                QMessageBox.warning(self, 'Warning', str(call))
            return
        except ParseException as exc:
            log(method='gui.Window.add_to_library_from_label', message='Error parsing webpage', error=str(exc), doi=doi,
                ref_index=index, main_lookup=referencing_paper)
            if popups:
                QMessageBox.warning(self, 'Warning', str(exc))
        except TypeError or AttributeError as exc:
            log(method='gui.Window.add_to_library_from_label', message='Error parsing webpage', error=str(exc), doi=doi,
                ref_index=index, main_lookup=referencing_paper)
            if popups:
                QMessageBox.warning(self, 'Warning', 'Error parsing page.')
        except Exception as exc:
            log(method='gui.Window.add_to_library_from_label', error=str(exc), doi=doi,
                ref_index=index, main_lookup=referencing_paper)
            if popups:
                QMessageBox.warning(self, 'Warning', str(exc))
        self._update_document_status(doi, label=label, adding=True, popups=popups)
Exemplo n.º 4
0
    def add_to_library_from_main(self):
        """
        Adds paper corresponding to the DOI in the text field to the user library,
        if it is not already there.
        """
        if self.is_in_lib:
            QMessageBox.information(self, 'Information', 'Paper is already in library.')
            return

        doi = self._get_doi()

        try:
            self.library.add_to_library(doi)
        except UnsupportedPublisherError as exc:
            log(method='gui.Window.add_to_library_from_main', message='Unsupported publisher', error=str(exc), doi=doi)
            QMessageBox.warning(self, 'Warning', 'Publisher is not yet supported.\n'
                                                 'Document not added.')
            return
        except CallFailedException as call:
            log(method='gui.Window.add_to_library_from_main', message='Call failed', error=str(call), doi=doi)
            QMessageBox.warning(self, 'Warning', str(call))
        except ParseException or AttributeError as exc:
            log(method='gui.Window.add_to_library_from_main', message='Error while parsing article webpage',
                error=str(exc), doi=doi)
            QMessageBox.warning(self, 'Warning', 'Error while parsing article webpage.')
        except Exception as exc:
            log(method='gui.Window.add_to_library_from_main', error=str(exc), doi=doi)
            QMessageBox.warning(self, 'Warning', str(exc))
        self._update_document_status(doi, adding=True)
        self.update_indicator()
Exemplo n.º 5
0
    def get_refs(self):
        """
        Gets references for paper corresponding to the DOI in text field.
        Displays reference information in scrollable area.
        """
        self.stacked_responses.hide()

        # Get DOI from text field and handle blank entry
        entered_doi = self._get_doi()
        self._populate_response_widget()

        if entered_doi == '':
            self.stacked_responses.setCurrentIndex(0)
            self.stacked_responses.show()
            return

        # Resolve DOI and get references
        try:
            paper_info = rr.resolve_doi(entered_doi)
            refs = paper_info.references
            self._populate_data(paper_info)
        except UnsupportedPublisherError as exc:
            log(method='gui.Window.get_refs', message='Unsupported Publisher', error=str(exc), doi=entered_doi)
            QMessageBox.warning(self, 'Warning', 'Unsupported Publisher')
            return
        except ParseException or AttributeError as exc:
            log(method='gui.Window.get_refs', message='Error parsing journal page', error=str(exc), doi=entered_doi)
            QMessageBox.warning(self, 'Warning', 'Error parsing journal page')
            return
        except Exception as exc:
            log(method='gui.Window.get_refs', error=str(exc), doi=entered_doi)
            QMessageBox.warning(self, 'Warning', str(exc))

        # First clean up existing GUI window.
        # If there are widgets in the layout (i.e. from the last call to 'get_refs'),
        # delete all of those reference labels before adding more.
        _delete_all_widgets(self.ref_items_layout)

        for ref in refs:
            ref_label = self.ref_to_label(ref)
            self.ref_items_layout.insertWidget(self.ref_area_layout.count() - 1, ref_label)

        self.ref_area.show()
Exemplo n.º 6
0
	dynamixel = ['dynamixel not responding','cant connect']
	lookup = []
	status_packet_handling  = ['input voltage error','angle limit error',\
	'overheting error','range error','checksum error','overload error',\
	'instruction error','invalid error byte']
	py_main = []

	module_names = {
		'arduino' : arduino,
		'dynamixel' : dynamixel,
		'lookup' : lookup,
		'status_packet_handling' : status_packet_handling,
		'py_main' : py_main,
	}

	if module_name in module_names.keys() and\
		exception_name in module_names[module_name] :
		
		gui.EXCEPTION_MODULE = module_name
		gui.EXCEPTION = exception_name
		error_logging.log(module_name + ':' + exception_name)
		gui.exception_caught(*args)
		gui.some_file.n = int(args[0])
		
	else : 
		print('invalid exception')
		print()


error_logging.log('rana here')
Exemplo n.º 7
0
	
	arduino = ['arduino not responding','cant connect']
	dynamixel = ['dynamixel not responding','cant connect']
	lookup = []
	status_packet_handling  = ['input voltage error','angle limit error',\
	'overheting error','range error','checksum error','overload error',\
	'instruction error','invalid error byte']
	py_main = []

	module_names = {
		'arduino' : arduino,
		'dynamixel' : dynamixel,
		'lookup' : lookup,
		'status_packet_handling' : status_packet_handling,
		'py_main' : py_main,
	}

	if module_name in module_names.keys() and\
		exception_name in module_names[module_name] :
		gui.EXCEPTION_MODULE = module_name
		gui.EXCEPTION = exception_name
		error_logging.log(module_name + '--> ' + exception_name)
		gui.exception_caught(*args)
		gui.some_file.n = int(args[0])
		
	else : 
		print('invalid exception')
		print()

error_logging.log('some error')