示例#1
0
 def on_data(self, name, data):
     if name == 'create_user':
         del data['name']
         try:
             floorc = self.BASE_FLOORC + '\n'.join(['%s %s' % (k, v) for k, v in data.items()]) + '\n'
             with open(G.FLOORC_PATH, 'w') as floorc_fd:
                 floorc_fd.write(floorc)
             utils.reload_settings()
             if False in [bool(x) for x in (G.USERNAME, G.API_KEY, G.SECRET)]:
                 editor.error_message('Something went wrong. You will need to sign up for an account to use Floobits.')
                 api.send_error('No username or secret')
             else:
                 p = os.path.join(G.BASE_DIR, 'welcome.md')
                 with open(p, 'w') as fd:
                     text = editor.welcome_text % (G.USERNAME, self.proto.host)
                     fd.write(text)
                 d = utils.get_persistent_data()
                 d['auto_generated_account'] = True
                 utils.update_persistent_data(d)
                 G.AUTO_GENERATED_ACCOUNT = True
                 editor.open_file(p)
         except Exception as e:
             msg.debug(traceback.format_exc())
             msg.error(str(e))
         try:
             d = utils.get_persistent_data()
             d['disable_account_creation'] = True
             utils.update_persistent_data(d)
         finally:
             self.proto.stop()
示例#2
0
 def _on_create_user(self, data):
     try:
         del data['name']
         floorc_json = {
             'auth': {}
         }
         floorc_json['auth'][G.DEFAULT_HOST] = data
         utils.save_floorc_json(floorc_json)
         utils.reload_settings()
         if utils.can_auth():
             p = os.path.join(G.BASE_DIR, 'welcome.md')
             with open(p, 'w') as fd:
                 username = G.AUTH.get(self.proto.host, {}).get('username')
                 text = editor.NEW_ACCOUNT_TXT.format(username=username, host=self.proto.host)
                 fd.write(text)
             d = utils.get_persistent_data()
             d['auto_generated_account'] = True
             utils.update_persistent_data(d)
             G.AUTO_GENERATED_ACCOUNT = True
             editor.open_file(p)
         else:
             editor.error_message('Something went wrong. You will need to sign up for an account to use Floobits.')
             api.send_error('No username or secret')
     except Exception as e:
         msg.debug(traceback.format_exc())
         msg.error(str_e(e))
     finally:
         try:
             d = utils.get_persistent_data()
             d['disable_account_creation'] = True
             utils.update_persistent_data(d)
         finally:
             self.stop()
示例#3
0
 def _on_create_user(self, data):
     try:
         del data['name']
         floorc_json = {'auth': {}}
         floorc_json['auth'][G.DEFAULT_HOST] = data
         utils.save_floorc_json(floorc_json)
         utils.reload_settings()
         if utils.can_auth():
             p = os.path.join(G.BASE_DIR, 'welcome.md')
             with open(p, 'w') as fd:
                 username = G.AUTH.get(self.proto.host, {}).get('username')
                 text = editor.NEW_ACCOUNT_TXT.format(username=username,
                                                      host=self.proto.host)
                 fd.write(text)
             d = utils.get_persistent_data()
             d['auto_generated_account'] = True
             utils.update_persistent_data(d)
             G.AUTO_GENERATED_ACCOUNT = True
             editor.open_file(p)
         else:
             editor.error_message(
                 'Something went wrong. You will need to sign up for an account to use Floobits.'
             )
             api.send_error('No username or secret')
     except Exception as e:
         msg.debug(traceback.format_exc())
         msg.error(str_e(e))
     finally:
         try:
             d = utils.get_persistent_data()
             d['disable_account_creation'] = True
             utils.update_persistent_data(d)
         finally:
             self.stop()
示例#4
0
 def on_data(self, name, data):
     if name == 'credentials':
         with open(G.FLOORC_PATH, 'w') as floorc_fd:
             floorc = self.BASE_FLOORC + '\n'.join(['%s %s' % (k, v) for k, v in data['credentials'].items()]) + '\n'
             floorc_fd.write(floorc)
         utils.reload_settings()
         if not G.USERNAME or not G.SECRET:
             editor.message_dialog('Something went wrong. See https://%s/help/floorc/ to complete the installation.' % self.proto.host)
             api.send_error({'message': 'No username or secret'})
         else:
             p = os.path.join(G.BASE_DIR, 'welcome.md')
             with open(p, 'w') as fd:
                 text = WELCOME_MSG % (G.USERNAME, self.proto.host)
                 fd.write(text)
             editor.open_file(p)
         self.proto.stop()
 def on_data(self, name, data):
     if name == 'credentials':
         s = utils.load_floorc_json()
         auth = s.get('AUTH', {})
         auth[self.proto.host] = data['credentials']
         s['AUTH'] = auth
         utils.save_floorc_json(s)
         utils.reload_settings()
         self.success = utils.can_auth(self.proto.host)
         if not self.success:
             editor.error_message('Something went wrong. See https://%s/help/floorc to complete the installation.' % self.proto.host)
             api.send_error('No username or secret')
         else:
             p = os.path.join(G.BASE_DIR, 'welcome.md')
             with open(p, 'w') as fd:
                 text = WELCOME_MSG % (G.AUTH.get(self.proto.host, {}).get('username'), self.proto.host)
                 fd.write(text)
             editor.open_file(p)
         self.stop()
 def on_data(self, name, data):
     if name == 'credentials':
         with open(G.FLOORC_PATH, 'w') as floorc_fd:
             floorc = self.BASE_FLOORC + '\n'.join(
                 ['%s %s' % (k, v)
                  for k, v in data['credentials'].items()]) + '\n'
             floorc_fd.write(floorc)
         utils.reload_settings()
         if not utils.can_auth():
             editor.error_message(
                 'Something went wrong. See https://%s/help/floorc to complete the installation.'
                 % self.proto.host)
             api.send_error('No username or secret')
         else:
             p = os.path.join(G.BASE_DIR, 'welcome.md')
             with open(p, 'w') as fd:
                 text = WELCOME_MSG % (G.AUTH.get(
                     self.proto.host, {}).get('username'), self.proto.host)
                 fd.write(text)
             editor.open_file(p)
         self.proto.stop()
 def on_data(self, name, data):
     if name == 'credentials':
         s = utils.load_floorc_json()
         auth = s.get('AUTH', {})
         auth[self.proto.host] = data['credentials']
         s['AUTH'] = auth
         utils.save_floorc_json(s)
         utils.reload_settings()
         self.success = utils.can_auth(self.proto.host)
         if not self.success:
             editor.error_message(
                 'Something went wrong. See https://%s/help/floorc to complete the installation.'
                 % self.proto.host)
             api.send_error('No username or secret')
         else:
             p = os.path.join(G.BASE_DIR, 'welcome.md')
             with open(p, 'w') as fd:
                 text = WELCOME_MSG % (G.AUTH.get(
                     self.proto.host, {}).get('username'), self.proto.host)
                 fd.write(text)
             editor.open_file(p)
         self.stop()
示例#8
0
 def _on_credentials(self, data):
     s = utils.load_floorc_json()
     auth = s.get('AUTH', {})
     auth[self.proto.host] = data['credentials']
     s['AUTH'] = auth
     utils.save_floorc_json(s)
     utils.reload_settings()
     self.success = utils.can_auth(self.proto.host)
     if not self.success:
         editor.error_message('Something went wrong. See https://%s/help/floorc to complete the installation.' % self.proto.host)
         api.send_error('No username or secret')
     else:
         p = os.path.join(G.BASE_DIR, 'welcome.md')
         with open(p, 'w') as fd:
             username = G.AUTH.get(self.proto.host, {}).get('username')
             text = editor.LINKED_ACCOUNT_TXT.format(username=username, host=self.proto.host)
             fd.write(text)
         editor.open_file(p)
     try:
         self.stop()
     except Exception as e:
         print(str_e(e))