コード例 #1
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def unsubscribe(self, channel_name, name, send_hook=False):
     if not self.server.exists_channel(channel_name):
         raise ExpectedException("Channel %s doesn't exist" %
                                 (channel_name, ))
     if not self.server.exists_user(name):
         raise ExpectedException("User %s doesn't exist" % (name, ))
     channel = self.server.get_channel(None, channel_name)
     user = self.server.get_user(name)
     channel.unsubscribe(user, needs_auth=send_hook)
コード例 #2
0
ファイル: admin.py プロジェクト: zorun/hookbox
 def frame_LOGIN(self, id, args):
     if self.logged_in:
         raise ExpectedException("Already logged in")
     if not self.config['admin_password'] or self.config[
             'admin_password'] != args['password']:
         raise ExpectedException("Invalid admin password")
     self.logged_in = True
     self._admin_app.login(self)
     self.send_frame("CONNECTED", {'version': hookbox.__version__})
     self.start_loop('overview')
コード例 #3
0
ファイル: web.py プロジェクト: skaughtx0r/hookbox
    def render_subscribe(self, form, start_response):
        channel_name = form.get('channel_name', None)
        if not channel_name:
            raise ExpectedException("Missing channel_name")
        name = form.get('name', None)
        if not name:
            raise ExpectedException("Missing name")
        send_hook = form.get('send_hook', '0') == '1'

        self.api.subscribe(channel_name, name, send_hook)
        start_response('200 Ok', [])
        return json.dumps([True, {}])
コード例 #4
0
ファイル: web.py プロジェクト: arjunasuresh3/hookbox
 def render_set_channel_options(self, form, start_response):
     channel_name = form.pop('channel_name', None)
     if not channel_name:
         raise ExpectedException("Missing channel_name")
     for key, val in form.items():
         try:
             form[key] = json.loads(val)
         except:
             raise ExpectedException("Invalid json value for option %s" % (key,))
     self.api.set_channel_options(channel_name, form)
     start_response('200 Ok', [])
     return json.dumps([True, {}])
コード例 #5
0
ファイル: web.py プロジェクト: skaughtx0r/hookbox
    def render_message(self, form, start_response):
        sender_name = form.get('sender_name', None)
        if not sender_name:
            raise ExpectedException("Missing sender_name")
        recipient_name = form.get('recipient_name', None)
        if not recipient_name:
            raise ExpectedException("Missing recipient_name")
        payload = form.get('payload', 'null')
        send_hook = form.get('send_hook', '0') == '1'

        self.api.message(sender_name, recipient_name, payload, send_hook)
        start_response('200 Ok', [])
        return json.dumps([True, {}])
コード例 #6
0
ファイル: web.py プロジェクト: skaughtx0r/hookbox
 def render_state_set_key(self, form, start_response):
     channel_name = form.pop('channel_name', None)
     if not channel_name:
         raise ExpectedException("Missing channel_name")
     if 'key' not in form:
         raise ExpectedExcpetion("Missing 'key' argument")
     if 'val' not in form:
         raise ExpectedException("Missing 'val' argument")
     try:
         val = json.loads(form['val'])
     except:
         raise ExpectedException('Invalid json: "%s"' % (val, ))
     self.api.state_set_key(channel_name, form['key'], val)
     start_response('200 Ok', [])
     return json.dumps([True, {}])
コード例 #7
0
ファイル: web.py プロジェクト: skaughtx0r/hookbox
 def render_get_channel_info(self, form, start_response):
     channel_name = form.get('channel_name', None)
     if not channel_name:
         raise ExpectedException("Missing channel_name")
     info = self.api.get_channel_info(channel_name)
     start_response('200 Ok', [])
     return json.dumps([True, info])
コード例 #8
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def create_channel(self, channel_name, options, send_hook=False):
     if self.server.exists_channel(channel_name):
         raise ExpectedException("Channel %s already exists" %
                                 (channel_name, ))
     self.server.create_channel(None,
                                channel_name,
                                options,
                                needs_auth=send_hook)
コード例 #9
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def message(self,
             sender_name,
             recipient_name,
             payload='null',
             send_hook=False):
     if not self.server.exists_user(sender_name):
         raise ExpectedException("User %s doesn't exist" % (sender_name, ))
     sender = self.server.get_user(sender_name)
     sender.send_message(recipient_name, payload, needs_auth=send_hook)
コード例 #10
0
ファイル: web.py プロジェクト: skaughtx0r/hookbox
 def render_state_delete_key(self, form, start_response):
     channel_name = form.pop('channel_name', None)
     if not channel_name:
         raise ExpectedException("Missing channel_name")
     if 'key' not in form:
         raise ExpectedExcpetion("Missing 'key' argument")
     self.api.state_delete_key(channel_name, key)
     start_response('200 Ok', [])
     return json.dumps([True, {}])
コード例 #11
0
ファイル: web.py プロジェクト: zorun/hookbox
 def render_publish(self, form, start_response):
     channel_name = form.get('channel_name', None)
     if not channel_name:
         raise ExpectedException("Missing channel_name")
     payload = form.get('payload', 'null')
     originator = form.get('originator', None)
     send_hook = form.get('send_hook', '0') == '1'
     self.api.publish(channel_name, payload, originator, send_hook)
     start_response('200 Ok', [])
     return json.dumps([True, {}])
コード例 #12
0
ファイル: web.py プロジェクト: arjunasuresh3/hookbox
 def render_set_config(self, form, start_response):
     
     for key in form:
         try:
             form[key] = json.loads(form[key])
         except:
             raise ExpectedException("Invalid json value for form key '%s'" % (key,))
     self.api.set_config(form)
     start_response('200 Ok', [])
     return json.dumps([True, {}])
コード例 #13
0
ファイル: web.py プロジェクト: arjunasuresh3/hookbox
 def render_publish_multi(self, form, start_response):
     channel_names = form.get('channel_names', None)
     assert(isinstance(channel_names, str))
     if not channel_names:
         raise ExpectedException("Missing channel_names")
     channel_name_list = channel_names.split(',')
     payload = form.get('payload', 'null')
     originator = form.get('originator', None)
     send_hook = form.get('send_hook', '0') == '1'
     self.api.publish_multi(channel_name_list, payload, originator, send_hook)
     start_response('200 Ok', [])
     return json.dumps([True, {}])
コード例 #14
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def publish(self,
             channel_name,
             payload='null',
             originator=None,
             send_hook=False):
     if not self.server.exists_channel(channel_name):
         if not self.config.ignore_publish_non_existing_channels:
             raise ExpectedException("Channel %s doesn't exist" %
                                     (channel_name, ))
         else:
             return
     channel = self.server.get_channel(None, channel_name)
     channel.publish(self,
                     payload,
                     needs_auth=send_hook,
                     originator=originator)
コード例 #15
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def destroy_channel(self, channel_name, send_hook=False):
     # NOTE: "already exists" errors will be raised as necessary by this method call
     if not self.server.exists_channel(channel_name):
         raise ExpectedException("Channel %s doesn't exist" %
                                 (channel_name, ))
     self.server.destroy_channel(channel_name, needs_auth=send_hook)
コード例 #16
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def set_channel_options(self, channel_name, options):
     if not self.server.exists_channel(channel_name):
         raise ExpectedException("Channel %s doesn't exists" %
                                 (channel_name, ))
     channel = self.server.get_channel(None, channel_name)
     channel.update_options(**options)
コード例 #17
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def get_channel_info(self, channel_name):
     if not self.server.exists_channel(channel_name):
         raise ExpectedException("Channel %s doesn't exists" %
                                 (channel_name, ))
     channel = self.server.get_channel(None, channel_name)
     return channel.serialize()
コード例 #18
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def state_delete_key(self, channel_name, key):
     if not self.server.exists_channel(channel_name):
         raise ExpectedException("Channel %s doesn't exists" %
                                 (channel_name, ))
     channel = self.server.get_channel(None, channel_name)
     channel.state_del(key)
コード例 #19
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def get_user_info(self, user_name):
     if not self.server.exists_user(user_name):
         raise ExpectedException("User %s doesn't exists" % (user_name, ))
     user = self.server.get_user(user_name)
     return user.serialize()
コード例 #20
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def set_user_options(self, user_name, options):
     if not self.server.exists_user(user_name):
         raise ExpectedException("User %s doesn't exists" % (user_name, ))
     user = self.server.get_user(user_name)
     user.update_options(**options)
コード例 #21
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def disconnect_user(self, name):
     raise ExpectedException("Not Implemented")
     if not self.server.exists_user(name):
         raise ExpectedException("User %s doesn't exist" % (name, ))
     user = self.server.get_user(name)
コード例 #22
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def disconnect(self, identifier):
     raise ExpectedException("Not Implemented")
コード例 #23
0
ファイル: internal.py プロジェクト: arjunasuresh3/hookbox
 def authorize(self, secret):
     if secret != self.config['api_security_token']:
         raise ExpectedException("Invalid Security Token")