コード例 #1
0
ファイル: __init__.py プロジェクト: thundur/kninfra
 def handle(self, d):
     with self.operation_lock:
         if d['type'] == 'sync':
             return self.sync()
         elif d['type'] == 'setpass':
             u = Es.by_name(d['user'])
             if u is None:
                 return {'error': 'no such user'}
             u = u.as_user()
             if not u.check_password(d['oldpass']):
                 return {'error': 'wrong old password'}
             u.set_password(d['newpass'])
             d2 = {'type': 'setpass',
                   'user': d['user'],
                   'pass': d['newpass']}
             self.daan.send(d2)
             self.cilia.send(d2)
             return {'success': True}
         elif d['type'] == 'set-villanet-password':
             u = Es.by_name(d['user'])
             if u is None:
                 return {'error': 'no such user'}
             u = u.as_user()
             if not u.check_password(d['oldpass']):
                 return {'error': 'wrong current password'}
             pc = Es.PushChange({'system': 'villanet',
                 'action': 'changeUser', 'data': {
                     'username': d['user'],
                     'password': self.villanet_encrypt_password(d['newpass'])
                         }})
             pc.save()
             self.push_changes_event.set()
             return {'success': True}
         elif d['type'] == 'fotoadmin-move-fotos':
             # TODO should this block Giedo?
             ret = self.daan.send(d)
             if 'success' not in ret:
                 return ret
             return self.cilia.send({
                 'type': 'fotoadmin-remove-moved-fotos',
                 'user': d['user'],
                 'dir': d['dir']})
         elif d['type'] == 'openvpn_create':
             # XXX hoeft niet onder de operation_lock
             u = Es.by_name(d['user'])
             if u is None:
                 return {'error': 'no such user'}
             u = u.as_user()
             if d['want'] == 'exe':
                 create_openvpn_installer(self, u)
             else:
                 create_openvpn_zip(self, u)
         elif d['type'] == 'update-site-agenda':
             return update_site_agenda(self)
         elif d['type'] in ['update-knsite', 'update-knfotos',
                 'fotoadmin-create-event']:
             return self.daan.send(d)
         else:
             logging.warn("Unknown command: %s" % d['type'])
コード例 #2
0
ファイル: __init__.py プロジェクト: spr3nk3ls/kninfra
 def handle(self, d):
     with self.operation_lock:
         if d["type"] == "sync":
             return self.sync()
         elif d["type"] == "setpass":
             u = Es.by_name(d["user"])
             if u is None:
                 return {"error": "no such user"}
             u = u.as_user()
             if not u.check_password(d["oldpass"]):
                 return {"error": "wrong old password"}
             u.set_password(d["newpass"])
             d2 = {"type": "setpass", "user": d["user"], "pass": d["newpass"]}
             self.daan.send(d2)
             self.cilia.send(d2)
             return {"success": True}
         elif d["type"] == "fotoadmin-move-fotos":
             # TODO should this block Giedo?
             ret = self.daan.send(d)
             if "success" not in ret:
                 return ret
             return self.cilia.send({"type": "fotoadmin-remove-moved-fotos", "user": d["user"], "dir": d["dir"]})
         elif d["type"] == "openvpn_create":
             # XXX hoeft niet onder de operation_lock
             u = Es.by_name(d["user"])
             if u is None:
                 return {"error": "no such user"}
             u = u.as_user()
             if d["want"] == "exe":
                 create_openvpn_installer(self, u)
             else:
                 create_openvpn_zip(self, u)
         elif d["type"] == "update-site-agenda":
             return update_site_agenda(self)
         elif d["type"] in ["update-knsite", "update-knfotos", "fotoadmin-create-event"]:
             return self.daan.send(d)
         else:
             print "Unknown command: %s" % d["type"]
コード例 #3
0
ファイル: __init__.py プロジェクト: aykevl/kninfra
 def handle(self, d):
     if d['type'] == 'sync':
         with self.operation_lock:
             return self.sync()
     elif d['type'] == 'setpass':
         with self.operation_lock:
             u = Es.by_name(d['user'])
             if u is None:
                 return {'error': 'no such user'}
             u = u.as_user()
             if not u.check_password(d['oldpass']):
                 return {'error': 'wrong old password'}
             u.set_password(d['newpass'])
             d2 = {'type': 'setpass',
                   'user': d['user'],
                   'pass': d['newpass']}
             self.daan.send(d2)
             self.cilia.send(d2)
             return {'success': True}
     elif d['type'] == 'ping':
         return {'pong': True}
     elif d['type'] == 'fotoadmin-scan-userdirs':
         return self.cilia.send(d)
     elif d['type'] == 'fotoadmin-move-fotos':
         with self.operation_lock:
             ret = self.daan.send(d)
             if 'success' not in ret:
                 return ret
             ret = scan_fotos()
             if 'success' not in ret:
                 return ret
             return self.cilia.send({
                 'type': 'fotoadmin-remove-moved-fotos',
                 'store': d['store'],
                 'user': d['user'],
                 'dir': d['dir']})
     elif d['type'] == 'fotoadmin-scan-fotos':
         with self.operation_lock:
             return scan_fotos()
     elif d['type'] == 'openvpn_create':
         with self.operation_lock:
             # XXX hoeft niet onder de operation_lock?
             u = Es.by_name(d['user'])
             if u is None:
                 return {'error': 'no such user'}
             u = u.as_user()
             if d['want'] == 'exe':
                 create_openvpn_installer(self, u)
             else:
                 create_openvpn_zip(self, u)
     elif d['type'] == 'update-site-agenda':
         with self.operation_lock:
             return update_site_agenda(self)
     elif d['type'] in ['fotoadmin-create-event']:
         with self.operation_lock:
             return self.daan.send(d)
     elif d['type'] == 'last-synced?':
         return self.last_sync_ts
     elif d['type'] in ('fin-get-account',
                        'fin-get-debitors',
                        'fin-check-names',
                        'fin-get-gnucash-object',
                        'fin-get-years',
                        'fin-get-errors'):
         return self.moniek.send(d)
     elif d['type'] in ('maillist-get-moderated-lists',
                        'maillist-activate-moderation',
                        'maillist-get-moderator-cookie',
                        'maillist-deactivate-moderation'):
         return self.hans.send(d)
     else:
         logging.warn("Unknown command: %s" % d['type'])
コード例 #4
0
ファイル: __init__.py プロジェクト: Jille/kninfra
 def handle(self, d):
     if d['type'] == 'sync':
         with self.operation_lock:
             return self.sync()
     elif d['type'] == 'setpass':
         with self.operation_lock:
             u = Es.by_name(d['user'])
             if u is None:
                 return {'error': 'no such user'}
             u = u.as_user()
             if not u.check_password(d['oldpass']):
                 return {'error': 'wrong old password'}
             u.set_password(d['newpass'])
             d2 = {
                 'type': 'setpass',
                 'user': d['user'],
                 'pass': d['newpass']
             }
             self.daan.send(d2)
             self.cilia.send(d2)
             return {'success': True}
     elif d['type'] == 'set-villanet-password':
         with self.operation_lock:
             u = Es.by_name(d['user'])
             if u is None:
                 return {'error': 'no such user'}
             u = u.as_user()
             if not u.check_password(d['oldpass']):
                 return {'error': 'wrong current password'}
             pc = Es.PushChange({
                 'system': 'villanet',
                 'action': 'changeUser',
                 'data': {
                     'username': d['user'],
                     'password':
                     self.villanet_encrypt_password(d['newpass'])
                 }
             })
             pc.save()
             self.push_changes_event.set()
             return {'success': True}
     elif d['type'] == 'fotoadmin-move-fotos':
         with self.operation_lock:
             # TODO should this block Giedo?
             ret = self.daan.send(d)
             if 'success' not in ret:
                 return ret
             return self.cilia.send({
                 'type': 'fotoadmin-remove-moved-fotos',
                 'user': d['user'],
                 'dir': d['dir']
             })
     elif d['type'] == 'openvpn_create':
         with self.operation_lock:
             # XXX hoeft niet onder de operation_lock?
             u = Es.by_name(d['user'])
             if u is None:
                 return {'error': 'no such user'}
             u = u.as_user()
             if d['want'] == 'exe':
                 create_openvpn_installer(self, u)
             else:
                 create_openvpn_zip(self, u)
     elif d['type'] == 'update-site-agenda':
         with self.operation_lock:
             return update_site_agenda(self)
     elif d['type'] in [
             'update-knsite', 'update-knfotos', 'fotoadmin-create-event'
     ]:
         with self.operation_lock:
             return self.daan.send(d)
     elif d['type'] == 'last-synced?':
         return self.last_sync_ts
     else:
         logging.warn("Unknown command: %s" % d['type'])