Exemplo n.º 1
0
 def sSaveProfile(self):
     #gui dialog                        
     filename = uiAccesories.getSaveFileName("Save Profile","profiles", "Profile Files (*.json)", "neni treba")               
     if(filename == ""):                        
         return  
     
     permanentdata = dstore.GetAllPermanents()
     
     json.dump(permanentdata, codecs.open(filename, 'w', 'utf-8'), ensure_ascii = False, indent = 4)
     uiAccesories.sGuiSetItem("racesettings-app", ["profile"], utils.toUnicode(filename))
Exemplo n.º 2
0
    def sExport(self, mode, dialog):
        
        print "I: ", self.name, ": export"

        if (mode == self.eTABLE):                
            format = "Csv"            
        elif mode == self.eWWW:
            format = "Htm"  
        elif mode == self.eDB:
            format = "Db"          
        else:
            print "sExport: ERROR"
            
                
        '''get filename, gui dialog, save path to datastore'''                        
        if dialog:
            print "as", "dir_export_"+format.lower()         
            filename = uiAccesories.getSaveFileName("Export table "+self.name+" to "+format.upper(),"dir_export_"+format.lower(), format.upper()+" Files (*."+format.lower()+")", self.name+"."+format.lower())
        else:
            filename = utils.get_filename("export/"+format.lower()+"/"+self.name+"_"+dstore.GetItem("racesettings-app",['race_name'])+"."+format.lower())
                     
        if(filename == ""):
            return                
                
        title = "Table '"+self.name + "'"+format.upper()+" Export"                        
                
        '''Write to the file'''
        if format == "Csv":
            
            #export times (with collumn's names)            
            try:
                self.model.df.to_csv(filename, ";", mode="w", index = False, encoding = "utf8", float_format = "%g")                
            except IOError:
                uiAccesories.showMessage(self.name+" Export warning", "File "+filename+"\nPermission denied!")                                                                                
        elif format == "Htm":                    
            '''Write to HTML file'''            
            try:                                                                
                html_page = ew_html.Page_table(filename, title = dstore.GetItem("racesettings-app", ['race_name']), styles= ["css/results.css",], lists = exportRows, keys = exportHeader)
                html_page.save()                             
                uiAccesories.showMessage(title, "Succesfully ("+filename+") : "+ time.strftime("%H:%M:%S", time.localtime()), msgtype = MSGTYPE.statusbar)            
            except IOError:            
                uiAccesories.showMessage(title, "NOT succesfully \n\nCannot write into the file ("+filename+")")