Ejemplo n.º 1
0
    def action_sync_server(self):
        state = {
            'd': self.name,
            'client_id': self.client_id,
        }
        url = self._request_server(path='/saas_server/sync_server',
                                   state=state,
                                   client_id=self.client_id)[0]
        res = requests.get(url,
                           verify=(self.request_scheme == 'https'
                                   and self.verify_ssl))
        if res.ok != True:
            msg = """Status Code - %s
Reason - %s
URL - %s
            """ % (res.status_code, res.reason, res.url)
            raise Warning(msg)
        data = simplejson.loads(res.text)
        for r in data:
            r['server_id'] = self.id
            client = self.env['saas_portal.client'].search([
                ('client_id', '=', r.get('client_id')),
            ])
            if not client:
                database = self.env['saas_portal.database'].search([
                    ('client_id', '=', r.get('client_id'))
                ])
                if database:
                    database.write(r)
                    continue
                client = self.env['saas_portal.client'].create(r)
            else:
                client.write(r)
        return None
Ejemplo n.º 2
0
    def action_sync_server(self):
        state = {
            'd': self.name,
            'client_id': self.client_id,
        }

        req, req_kwargs = self._request_server(path='/saas_server/sync_server', state=state, client_id=self.client_id)
        res = requests.Session().send(req, **req_kwargs)

        if res.ok != True:
            raise Warning('Reason: %s \n Message: %s' % (res.reason, res.content))
        data = simplejson.loads(res.text)

        for r in data:
            r['server_id'] = self.id
            client = self.env['saas_portal.client'].with_context(active_test=False).search([('client_id', '=', r.get('client_id'))])
            if not client:
                database = self.env['saas_portal.database'].search([('client_id', '=', r.get('client_id'))])
                if database:
                    database.write(r)
                    continue
                client = self.env['saas_portal.client'].create(r)
            else:
                client.write(r)
        return None
 def action_sync_server(self):
     state = {
         'd': self.name,
         'client_id': self.client_id,
     }
     url = self._request_server(path='/saas_server/sync_server',
                                state=state,
                                client_id=self.client_id)[0]
     res = requests.get(url,
                        verify=(self.request_scheme == 'https'
                                and self.verify_ssl))
     data = simplejson.loads(res.text)
     for r in data:
         r['server_id'] = self.id
         client = self.env['saas_portal.client'].search([
             ('client_id', '=', r.get('client_id')),
         ])
         if not client:
             database = self.env['saas_portal.database'].search([
                 ('client_id', '=', r.get('client_id'))
             ])
             if database:
                 database.write(r)
                 continue
             client = self.env['saas_portal.client'].create(r)
         else:
             client.write(r)
     return None
Ejemplo n.º 4
0
    def action_sync_server(self):
        state = {
            'd': self.name,
            'client_id': self.client_id,
        }
        url = self._request_server(path='/saas_server/sync_server', state=state, client_id=self.client_id)[0]
        res = requests.get(url, verify=(self.request_scheme == 'https' and self.verify_ssl))
        if res.ok != True:
            msg = """Status Code - %s
Reason - %s
URL - %s
            """ % (res.status_code, res.reason, res.url)            
            raise Warning(msg)
        data = simplejson.loads(res.text)
        for r in data:
            r['server_id'] = self.id
            client = self.env['saas_portal.client'].search([
                ('client_id', '=', r.get('client_id')),
            ])
            if not client:
                database = self.env['saas_portal.database'].search([('client_id', '=', r.get('client_id'))])
                if database:
                    database.write(r)
                    continue
                client = self.env['saas_portal.client'].create(r)
            else:
                client.write(r)
        return None
 def action_sync_server(self):
     state = {
         'd': self.name,
         'client_id': self.client_id,
     }
     url = self._request_server(path='/saas_server/sync_server', state=state, client_id=self.client_id)[0]
     res = requests.get(url)
     data = simplejson.loads(res.text)
     for r in data:
         r['server_id'] = self.id
         client = self.env['saas_portal.client'].search([
             ('client_id', '=', r.get('client_id')),
         ])
         if not client:
             database = self.env['saas_portal.database'].search([('client_id', '=', r.get('client_id'))])
             if database:
                 database.write(r)
                 continue
             client = self.env['saas_portal.client'].create(r)
         else:
             client.write(r)
     return None