def Open(self,file_prj=None): if file_prj == None: wildcard = "easyPy Project (*.epy)|*.epy|" \ "All files (*.*)|*.*" dlg = wx.FileDialog(self.parent, message = u"Seleccione Proyecto", defaultDir=os.path.join(os.getcwd(),'projects'), defaultFile="", wildcard=wildcard, style=wx.OPEN ) if dlg.ShowModal() == wx.ID_OK: paths = dlg.GetPaths() file_prj = paths[0] dlg.Destroy() #--- if file_prj==None: return -1 #--- config = ConfigParser.RawConfigParser() config.read(file_prj) idprj = config.get('CONFIG', 'ID') self.idprj = idprj #--- self.conn_gui = mydb.dbo(idprj) self.conn_gui.Connect('',epy_vars.FILE_GUI,new_table=1,ext='') self.conn_table = mydb.dbo(idprj) self.conn_table.Connect('',epy_vars.FILE_TABLES,new_table=1,ext='') self.conn_list = mydb.dbo(idprj) self.conn_list.Connect('',epy_vars.FILE_LIST,new_table=1,ext='') self.conn_rpt = mydb.dbo(idprj) self.conn_rpt.Connect('',epy_vars.FILE_RPT,new_table=1,ext='') self.config = config # return idprj
def Run(self): path_file = None wizard = self.wiz if wizard.RunWizard(self.page1): # idprj = self.page1.tx_prj.GetValue() autor = self.page1.tx_autor.GetValue() descr = self.page1.tx_descrip.GetValue() # core = self.page2.rb_core.GetSelection() ui = self.page2.rb_ui.GetSelection() # db = self.page3.rb_db.GetSelection() # path_prj = os.path.join(epy_vars.PATH_PRJ,idprj) if os.path.exists(path_prj): wx.MessageBox(u"Ya existe el proyecto "+idprj, "Atención") return None os.mkdir(path_prj) # config = ConfigParser.RawConfigParser() sec = "CONFIG" config.add_section(sec) config.set(sec,"ID",idprj) config.set(sec,"CORE",core) config.set(sec,"UI",ui) config.set(sec,"DB",db) # Writing our configuration file to 'example.cfg' path_file = os.path.join(epy_vars.PATH_PRJ,idprj+'.epy') with open(path_file, 'wb') as configfile: config.write(configfile) # Writing Files for nmf in (epy_vars.FILE_GUI,epy_vars.FILE_TABLES,epy_vars.FILE_LIST,epy_vars.FILE_RPT): f = mydb.dbo(idprj) f.Create_System_Table(nmf) #-Copy standard images img_std = os.path.join(epy_vars.PATH_IMG,'default') img_prj = os.path.join(epy_vars.PATH_PRJ,idprj,epy_vars.PATH_IMG_APL) shutil.copytree(img_std, img_prj) wx.MessageBox(u"Proyecto Creado", u"Asistente Completado") else: wx.MessageBox(u"Asistente Cancelado", u"Creación Cancelada!") # del wizard return path_file
def Test(evt): conn = mydb.dbo('gsges') table = 'zonas' conn.Connect('default',table) id=1 deno = 'MiFamilia' rgn={'IDX':id,'FM_DENO':deno} conn.Save(rgn) rg = conn.Load(id) print rg print '============' return # Probar acciones de la base de datos data = P.GetValue() acciones,columnas = data print 'Test::',columnas if not conn.Exists_Table(table): res = conn.Create_Table(table,columnas) print 'Create_Table',res else: #res = conn.Delete_Table(table) #print 'Delete',res """conn.Connect('test_eje',table) res = conn.Insert({'AR_DENO':'nombre', 'AR_PVP':5}) print 'Insert',res res = conn.Update('AR_ID=1',{'AR_DENO':'yomismo', 'AR_PVP':5}) print 'Update',res res = conn.Select('*' ,[['AR_PVP','>',2]]) #,['AR_DENO','LIKE','JOS%']]) print 'Select:' for rg in res: print rg """ conn.get_Info_Table('clientes')
def Save(self,project): name = self.Get_Name() data = self.GetValue() project.Save_Table(name,data) #-- (hacer para todos los ejercicios) !!! dir_prj = project.GetDir() dir_data = os.path.join(dir_prj,epy_vars.PATH_DATA_APL) if not os.path.exists(dir_data): os.makedirs(dir_data) lseje = os.listdir(dir_data) if lseje==[]: # Si no hay ejercicios, creamos uno por defecto os.makedirs(os.path.join(dir_data,'default')) lseje = ['default'] acciones,columnas = data apl = project.idprj conn = mydb.dbo(apl) conn.ruta = dir_data conn.Create_Table(name,columnas) conn.Disconnect() """for eje in lseje: file_table = os.path.join(dir_data,eje,name+'.db') if not os.path.exists(file_table): # No existe, crear la tabla conn = mydb.dbo(eje) conn.Create_Table(name,columnas) conn.Disconnect() else: import shutil # Ya existe el fichero rehacer estructura file_backup = file_table+'.backup' shutil.move(file_table,file_backup) conn = mydb.dbo(dir_data) conn.Create_Table(name,columnas) conn.Disconnect() """ #- self.SetModified(0) return 0
def Connect_Table(self): db = dbo.dbo(self._environ.apl) db.Connect(self._environ.eje, self._db_table) self._db_conn = db