def on_Back_up_Database_activate(self, widget): """ Si prepara un file zip con il dump del DB """ if Environment.tipodb == "sqlite": msg = _("""NELLA VERSIONE ONE IL BACKUP SI EFFETTUA COPIANDO IL FILE db CHE SI TROVA NELLA CARTELLA promogest2 IN /HOME/NOMEUTENTE/ O IN C:/UTENTI/NOMEUTENTE""") messageInfo(msg= msg) else: st = Environment.startdir() nameDump = "promoGest3_bkp_"+self.aziendaStr+"_"+ datetime.now().strftime('%d_%m_%Y_%H_%M')+".zip" msgg = _("""Il "dump" del database verrà salvato in %s ed avrà il nome %s ATTENZIONE!!!! la procedura potrebbe richiedere diversi minuti.""") %(st, nameDump) messageInfo(msg= msgg, transient=self.getTopLevel()) #if response == gtk.RESPONSE_OK: st = Environment.startdir() stname = st+nameDump os.environ["PGPASSWORD"] = Environment.password if os.name == "nt": PG_DUMP_ESEC = os.path.split(os.path.dirname(__file__))[0]+"\lib\pg_dump_dir\pg_dump.exe" elif os.name =="posix": PG_DUMP_ESEC = "pg_dump" else: messageInfo(msg="SU QUESTO SISTEMA OPERATIVO NON SI PUò FARE IL BACKUP DA QUI") retcode = call([PG_DUMP_ESEC, "-h",Environment.host, "-p",Environment.port, "-U",Environment.user, "-Z","7", "-f",stname, Environment.database]) Environment.pg2log.info("STO EFFETTUANDO UN BACKUP DEL FILE %s" %stname) if not retcode: Environment.pg2log.info("DUMP EFFETTUATO CON SUCCESSO") messageInfo(msg="BACKUP EFFETTUATO CON SUCCESSO") else: messageInfo(msg="BACKUP NON RIUSCITO") Environment.pg2log.info("ATTENZIONE DUMP NON RIUSCITO")
def on_test_promowear_button_clicked(self, button): msg = _( """PROVIAMO IL MODULO DI TAGLIA E COLORE o PROMOWEAR, Procedo? """ ) if not YesNoDialog(msg=msg, transient=self.getTopLevel()): return from data.createSchemaDb import orderedInstallPromoWear if orderedInstallPromoWear(): if not setconf("PromoWear","mod_enable",value="yes"): a = SetConf() a.section = "PromoWear" a.tipo_section ="Modulo" a.description = "Modulo Taglia e colore" a.tipo = "bool" a.key = "mod_enable" a.value = "yes" a.persist() messageInfo(msg=_("RIAVVIA IL PROMOGEST")) Environment.delete_pickle() Environment.restart_program()
def on_test_promoshop_button_clicked(self, button): from promogest.dao.Setconf import SetConf msg = _(""" PROVIAMO IL MODULO VENDITA DETTAGLIO o PROMOSHOP, Procedo? """) if not YesNoDialog(msg=msg, transient=self.getTopLevel()): return if not setconf("VenditaDettaglio","mod_enable",value="yes"): a = SetConf() a.section = "VenditaDettaglio" a.tipo_section ="Modulo" a.description = "Modulo Vendita Dettaglio" a.tipo = "bool" a.key = "mod_enable" a.value = "yes" a.persist() a = SetConf() a.section = "VenditaDettaglio" a.tipo_section ="Modulo" a.description = "Nome del movimento generato" a.tipo = "str" a.key = "operazione" a.value = "Scarico venduto da cassa" a.persist() a = SetConf() a.section = "VenditaDettaglio" a.tipo_section ="Modulo" a.description = "disabilita_stampa" a.tipo = "bool" a.key = "disabilita_stampa" a.value = "True" a.active = True a.persist() from data.createSchemaDb import orderedInstallVenditaDettaglio orderedInstallVenditaDettaglio() messageInfo(msg=_("RIAVVIA IL PROMOGEST")) Environment.delete_pickle() Environment.restart_program() else: messageInfo(msg=_("RISULTA GIA' ATTIVATO"))
def set_configuration(company=None, year = None, pg_path=None): dire = getConfigureDir(company) promogestDir = None if pg_path: promogestDir = os.path.join(pg_path, dire) + os.sep else: promogestDir = os.path.join(os.path.expanduser('~'), dire) + os.sep Environment.promogestDir = promogestDir if not (os.path.exists(promogestDir)): os.mkdir(promogestDir) cartelle = ["documenti", "tracciati", "temp", "templates", "label-templates", "images"] for c in cartelle: pa = promogestDir + c + os.sep if not (os.path.exists(pa)): os.mkdir(pa) if c == "documenti": Environment.documentsDir = pa elif c == "tracciati": Environment.tracciatiDir = pa elif c == "temp": Environment.tempDir = pa elif c == "images": Environment.imagesDir = pa elif c == "templates": Environment.templatesDir = pa slas = glob.glob(os.path.join(c, '*.sla')) for s in slas: try: with open(pa+s.split(os.sep)[1]) as f: pass except IOError as e: shutil.copy(s, pa) elif c == "label-templates": Environment.labelTemplatesDir = pa slas = glob.glob(os.path.join(c, '*.sla')) for s in slas: try: with open(pa+s.split(os.sep)[1]) as f: pass except IOError as e: shutil.copy(s, pa) try: configFile = promogestDir + 'configure' conf = Config(configFile) except IOError: configFile = promogestDir + 'configure' c = open('configure.dist','r') cont = c.readlines() fileConfig = open(configFile,'w') for row in cont[11:]: fileConfig.write(str(row)) c.close() fileConfig.close() Environment.__sendmail(msg=str(promogestDir)) conf = Config(configFile) conf.save() # Parametri localizzazione formati conf.windowsrc = promogestDir + 'windowsrc.xml' conf.guiDir = '.' + os.sep + 'gui' + os.sep #Anno di lavoro workingYear = None #[Composer] if hasattr(conf,'Composer'): conf.emailcompose = str(getattr(conf.Composer, 'emailcompose')) try: conf.subject = conf.Composer.subject except: conf.subject = "[ Invio Doc: %s ]" conf.signature = """Invio elettronico di %s effettuato tramite software gestionale PromoGest """ conf.body = conf.signature else: emailcompose = None #[Label] if hasattr(conf,'Label'): mod_enable = getattr(conf.Label,'mod_enable') if mod_enable: conf.hasLabel = True sistemaColonnaFrontaline = float(getattr(conf.Label, 'sistemacolonnafrontaline')) sistemaRigaFrontaline = float(getattr(conf.Label, 'sistemarigafrontaline')) #bordoDestro = float(getattr(conf.Label, 'bordodestro')) #bordoSinistro = float(getattr(conf.Label, 'bordosinistro')) else: conf.hasLabel = False sistemaColonnaFrontaline = 0 sistemaRigaFrontaline = 0 bordoDestro = None bordoSinistro = None else: conf.hasLabel = False importDebug = True return conf
def on_button_login_clicked(self, button=None): """ """ #username = self.username_comboxentry.child.get_text() username = self.username_entry.get_text() password = self.password_entry.get_text() if username == '' or password == '': messageInfo(msg=_('Inserire nome utente e password')) return elif Environment.engine.name != "sqlite" and \ findStrFromCombobox(self.azienda_combobox, 0) == '': messageInfo(msg=_("Occorre selezionare un'azienda")) return else: #if hasattr(self,"azienda_combobox"): self.azienda = findStrFromCombobox(self.azienda_combobox, 0) findComboboxRowFromStr(self.azienda_combobox, self.azienda, 0) self.azienda_combobox.get_active() != -1 #if not self.azienda: #self.azienda = "AziendaPromo" #superati i check di login users = User().select(username=username, password=hashlib.md5(username + password).hexdigest()) if not users: users = User().select(username=str(username).strip()) if users: try: from promogest.lib.utils import AESCipher, ops r = AESCipher(ops).decrypt( users[0].password) if r != password: messageInfo(msg=_('Password errata')) except: rows = [] if len(users) == 1: if users[0].active == False: messageInfo(msg=_('Utente Presente Ma non ATTIVO')) return else: Environment.workingYear = str(self.anno_lavoro_spinbutton.get_value_as_int()) oldSchema = Environment.params["schema"] Environment.azienda = self.azienda for a in self.azs: if a.schemaa == self.azienda: a.tipo_schemaa = "last" else: a.tipo_schemaa = "" Environment.session.add(a) Environment.session.commit() if Environment.tipodb == "postgresql": Environment.params["schema"] = self.azienda Environment.fk_prefix = Environment.params["schema"] + '.' if self.azienda not in Environment.meta._schemas: print(" PICKLE NON VA BENE") #Environment.azienda = oldSchema Environment.delete_pickle() # import pickle # cachefile = 'orm.p' # Environment.meta.create_all() # with open(cachefile, 'w') as cache: # pickle.dump(Environment.meta, cache) # cache.close() # Lancio la funzione di generazione della dir di configurazione from promogest.buildEnv import set_configuration Environment.conf = set_configuration(Environment.azienda, Environment.workingYear) # if setconf("Feed","feed"): # if True == True: # thread = threading.Thread(target=self.feddretreive) # thread.start() # thread.join(2.3) files = glob.glob(Environment.tempDir+"/*") for f in files: os.remove(f) Environment.params['usernameLoggedList'][0] = users[0].id Environment.params['usernameLoggedList'][1] =\ users[0].username try: Environment.params['usernameLoggedList'][2] =\ users[0].id_role except: Environment.params['usernameLoggedList'][2] = 1 if hasAction(actionID=1): self.login_window.hide() Environment.windowGroup.remove(self.getTopLevel()) installId() Environment.pg2log.info( "LOGIN id, user, role azienda: %s, %s" % ( repr(Environment.params['usernameLoggedList']), self.azienda)) checkInstallation() from promogest.dao.Setconf import SetConf avv = SetConf().select(key="avvii") if avv: avv[0].value = int(avv[0].value)+1 Environment.avvii = int(avv[0].value)+1 avv[0].persist() Environment.settaggi = Environment.session.query( SetConf.key, SetConf.value).all() Environment.pg2log.info( "SETAGGI: %s" % (str(Environment.settaggi))) self.importModulesFromDir('promogest/modules') # ATTENZIONE!!! RIATTIVARE!!! from promogest.dao.DaoOrderedImport import orderedImport orderedImport() def mainmain(): from Main import Main main = Main(self.azienda, self.anagrafiche_modules, self.parametri_modules, self.anagrafiche_dirette_modules, self.frame_modules, self.permanent_frames) main.getTopLevel().connect("destroy", on_main_window_closed, self.login_window) main.show() glib.idle_add(mainmain) else: messageInfo(msg=_('Nome utente o password errati, Riprova'))