Ejemplo n.º 1
0
 def test_should_be_print_error(self):
     err = ErrorLogger("Error.txt")
     try:
         raise Exception("Unknown Error on this code.")
     except Exception as e:
         error_text = err.get_error(e)
         print(error_text)
         self.assertEqual(type("str"), type(error_text))
Ejemplo n.º 2
0
 def test_should_save_error_log(self):
     log_file = "Error.txt"
     err = ErrorLogger(log_file)
     print("Running test 2")
     try:
         raise Exception("Another Error on this code.")
     except Exception as e:
         err.save(e)
         file_exists = os.path.exists(log_file)
         self.assertTrue(file_exists)
Ejemplo n.º 3
0
 def process_molecule(self, mol):
     # shortcut
     id2t = DataTypeFactory.data_type_from_id
     # the molecule
     mol_data = MultiView(id2t("MOLECULE"))
     # add different views
     try:
         names = oasa.structure_database.find_molecule_in_database(mol, database_file=os.path.join(sys.path[0],"oasa","oasa","structures.db"))
     except oasa.oasa_exceptions.oasa_inchi_error, e:
         ErrorLogger.warning("InChI program not properly installed, InChI and name generation won't work. Read README.setup for more info.")
Ejemplo n.º 4
0
def main():
    error_logger = ErrorLogger()
    warn_logger = WarnLogger()
    info_logger = InfoLogger()

    error_logger.set_next_logger(warn_logger)
    warn_logger.set_next_logger(info_logger)

    error_logger.log_message(2, "Test message")
    error_logger.log_message(5, "QA test")
Ejemplo n.º 5
0
    def write(self, data, update=False):

        date = data['date']
        values = data['values']
        records = []

        try:
            for k, v in values.items():
                for denomination, quantity, amount in v['specification']:
                    records.append((date, k, denomination, quantity, amount))

            if not update:
                self.c.executemany(
                    "INSERT INTO data(date, currency, denomination, quantity, amount) VALUES (?, ?, ?, ?, ?)",
                    records)

                if self.c.rowcount == 0:
                    tkMessageBox.showerror(
                        "Greška", "Neki podaci se nisu upisali u bazu")
                else:
                    tkMessageBox.showinfo("Obaveštenje",
                                          "Podaci su uspešno sačuvani")

            else:
                row_counts = []
                for date, currency, denomination, quantity, amount in records:
                    self.c.execute(
                        """
                    UPDATE data SET
                    quantity = ?,
                    amount = ?
                    WHERE date = ?
                    and currency = ?
                    and denomination = ?
                    """, [quantity, amount, date, currency, denomination])

                    row_counts.append(self.c.rowcount)

                if 0 in row_counts:
                    tkMessageBox.showerror(
                        "Greška", "Neki podaci se nisu upisali u bazu")
                else:
                    tkMessageBox.showinfo("Obaveštenje",
                                          "Podaci su uspešno sačuvani")

            self.conn.commit()
            self.conn.close()

            return True

        except Exception as error:
            error_description = "Došlo je do greške prilikom upisivanja podataka u bazu"
            tkMessageBox.showerror("Greška", error_description)
            ErrorLogger().log(error, error_description)

            return False
	def print_to_printer(self):
		# This only works on 32bit Windows!
		try:
			win32api.ShellExecute (0, "print", self.pdf_file, None, ".", 0)

			return True

		except Exception as error:
			error_description = "Došlo je do greške prilikom štampanja"
			tkMessageBox.showerror("Greška", error_description)
			ErrorLogger().log(error, error_description)

			return False
Ejemplo n.º 7
0
from error_logger import ErrorLogger

if __name__ == "__main__":
    # Declaring error logger
    err = ErrorLogger("ERROR.log")

    try:
        print("Paso 1")
        a, b, c = d

    except Exception as e:
        # Print error text and save the error
        print(err.get_error(e))
        err.save(e)

    try:
        print("Paso 2")
        raise Exception("Unknown Error on this code")

    except Exception as e:
        # Only save the error log
        err.save(e)