Ejemplo n.º 1
0
 def connection(self):
     con = Connection()
     con.user = self.args.user
     con.server = self.args.server
     con.port = self.args.port
     con.db = self.args.db
     con.get_password()
     con.connect()
     return con
Ejemplo n.º 2
0
    def run(self):
        from caloriestracker.connection_pg import Connection
        con=Connection()
        con.user=self.user
        con.server=self.server
        con.port=self.port
        con.db=self.db
        con.get_password("", "")
        con.connect()
        print("Is connection active?",  con.is_active())
        
        f=open("caloriestracker/hardcoded_strings.py", "w", encoding='utf-8')
        f.write("from PyQt5.QtWidgets import QApplication\n")
        
        rows=con.cursor_rows("select distinct(name) from products where companies_id is Null and elaboratedproducts_id is null order by name")
        for row in rows:
            f.write("QApplication.translate('HardcodedStrings','{}')\n".format(row["name"]))
            
        f.write("\n#Formats\n")
        rows=con.cursor_rows("select distinct(name) from formats order by name")
        for row in rows:
            f.write("QApplication.translate('HardcodedStrings','{}')\n".format(row["name"]))
            
        f.write("\n#Foodtypes\n")
        rows=con.cursor_rows("select * from foodtypes order by name")
        for row in rows:
            f.write("QApplication.translate('HardcodedStrings','{}')\n".format(row["name"]))

        f.close()
        con.disconnect()

        os.system("pylupdate5 -noobsolete -verbose caloriestracker.pro")
        os.system("lrelease -qt5 caloriestracker.pro")

        print("Updating Entity Relationship Schema")
        os.chdir("doc/html")
        os.system("/usr/bin/postgresql_autodoc -d {} -h {} -u {} -p {} --password={} -t html".format(self.db,self.server,self.user, self.port,con.password))
        os.system("/usr/bin/postgresql_autodoc -d {} -h {} -u {} -p {} --password={} -t dot_shortfk".format(self.db,self.server,self.user, self.port,con.password))
        os.system("dot -Tpng {0}.dot_shortfk -o {0}_er.png".format(self.db))
Ejemplo n.º 3
0
    def run(self):
        from caloriestracker.connection_pg import Connection
        con = Connection()
        con.user = self.user
        con.server = self.server
        con.port = self.port
        con.db = self.db
        con.get_password("", "")
        con.connect()
        print("Is connection active?", con.is_active())

        f = open("caloriestracker/hardcoded_strings.py", "w", encoding='utf-8')
        f.write("from PyQt5.QtCore import QT_TRANSLATE_NOOP\n")

        rows = con.cursor_rows(
            "select distinct(name) from products where companies_id is Null and elaboratedproducts_id is null order by name"
        )
        for row in rows:
            f.write("QT_TRANSLATE_NOOP('HardcodedStrings','{}')\n".format(
                row["name"]))

        f.write("\n#Formats\n")
        rows = con.cursor_rows(
            "select distinct(name) from formats order by name")
        for row in rows:
            f.write("QT_TRANSLATE_NOOP('HardcodedStrings','{}')\n".format(
                row["name"]))

        f.write("\n#Foodtypes\n")
        rows = con.cursor_rows("select * from foodtypes order by name")
        for row in rows:
            f.write("QT_TRANSLATE_NOOP('HardcodedStrings','{}')\n".format(
                row["name"]))

        f.close()
        con.disconnect()

        os.system("pylupdate5 -noobsolete -verbose caloriestracker.pro")
        os.system("lrelease -qt5 caloriestracker.pro")