Changeset 3421


Ignore:
Timestamp:
Jan 26, 2017, 12:46:01 PM (2 years ago)
Author:
daduve
Message:

Adding new function to share group in n4d variable and set user default at login screen

Location:
epoptes/trunk/fuentes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • epoptes/trunk/fuentes/debian/changelog

    r3230 r3421  
     1epoptes (0.5.9-lliurex20) xenial; urgency=high
     2
     3  * Adding new function to share group in n4d variable and set user
     4    default at login screen
     5
     6 -- Daniel Duran Vecino <daduve@gmail.com>  Thu, 26 Jan 2017 12:45:12 +0100
     7
    18epoptes (0.5.9-lliurex19) xenial; urgency=high
    29
  • epoptes/trunk/fuentes/epoptes/common/config.py

    r295 r3421  
    107107        return {}
    108108
    109 def read_groups(filename):
     109def read_groups(filename,n4d_mode=None):
    110110    """Parse a JSON file and create the appropriate group and
    111111    client objects.
     
    114114    instances list.
    115115    """
    116     try:
    117         f=open(filename)
    118         data = json.loads(f.read())
    119         f.close()
    120     except:
    121         return ([],[])
     116    if not n4d_mode:
     117        try:
     118            f=open(filename)
     119            data = json.loads(f.read())
     120            f.close()
     121        except:
     122            return ([],[])
     123    else:
     124        try:
     125            import xmlrpclib as x
     126            c=x.ServerProxy("https://server:9779")
     127            data=c.get_variable("","VariablesManager","EPOPTES_GROUPS")
     128
     129            #print "***** EPOPTES N4D DATA: [%s] ..."%data
     130            # If not exists value to EPOPTES GROUP in N4D, .config/epoptes/groups.json is listed
     131            if data==None or data=={}:
     132                f=open(filename)
     133                data = json.loads(f.read())
     134                f.close()
     135            #raise Exception
     136        except:
     137            return ([],[])
    122138   
    123139    saved_clients = {}
     
    137153    return (saved_clients.values(), groups)
    138154   
    139 def save_groups(filename, model):
     155def save_groups(filename, model,n4d_mode=None):
    140156    """Save the groups and their members from model (gtk.ListStore)
    141157    in JSON format.
     
    185201        f.write(json.dumps(data, indent=2))
    186202        f.close()
     203        #print "JSON ESCRITO"
    187204    except:
    188205        pass
     206    valor=str(n4d_mode)
     207    #print "N4D_MODE POSEEEEEEE EL VALOR DE: %s" %valor
     208    if n4d_mode!=None:
     209        import xmlrpclib as x
     210        c=x.ServerProxy("https://server:9779")
     211
     212        # Just in case EPOPTES_GROUPS Variable does not exist
     213        #print c.add_variable(n4d_mode,"VariablesManager","EPOPTES_GROUPS",{},"","Epoptes Groups",[],False,False)
     214        if c.add_group(n4d_mode,"EpoptesVariables",n4d_mode)[0]:
     215
     216                #print c.set_variable(n4d_mode,"VariablesManager","EPOPTES_GROUPS",data)
     217                c.set_group(n4d_mode,"EpoptesVariables",n4d_mode,data)
     218
    189219
    190220def write_history():
  • epoptes/trunk/fuentes/epoptes/ui/gui.py

    r3000 r3421  
    128128        self.reload_imagetypes()
    129129       
    130         saved_clients, groups = config.read_groups(os.path.expanduser('~/.config/epoptes/groups.json'))
     130        saved_clients, groups = config.read_groups(os.path.expanduser('~/.config/epoptes/groups.json'),True)
    131131        for grp in groups:
    132132            self.gstore.append([grp.name, grp, True])
     
    190190          sel_group = self.gstore.get_path(self.getSelectedGroup()[0])[0]
    191191          self.gstore.remove(self.gstore.get_iter(self.default_group.ref.get_path()))
    192           config.save_groups(os.path.expanduser('~/.config/epoptes/groups.json'), self.gstore)
     192          config.save_groups(os.path.expanduser('~/.config/epoptes/groups.json'), self.gstore,(self.n4d_user,self.n4d_password))
    193193          settings = config.settings
    194194          if not settings.has_section('GUI'):
Note: See TracChangeset for help on using the changeset viewer.