channelstream: python3 fixes
This commit is contained in:
parent
d7615d96b6
commit
9f12808488
1 changed files with 9 additions and 8 deletions
|
|
@ -19,7 +19,6 @@
|
|||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
import os
|
||||
import hashlib
|
||||
import itsdangerous
|
||||
import logging
|
||||
import requests
|
||||
|
|
@ -32,6 +31,8 @@ import rhodecode.lib.helpers as h
|
|||
from rhodecode.lib.auth import HasRepoPermissionAny
|
||||
from rhodecode.lib.ext_json import json
|
||||
from rhodecode.model.db import User
|
||||
from rhodecode.lib.str_utils import ascii_str
|
||||
from rhodecode.lib.hash_utils import sha1_safe
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -157,13 +158,13 @@ def parse_channels_info(info_result, include_channel_info=None):
|
|||
user_state_dict = {}
|
||||
for userinfo in info_result['users']:
|
||||
user_state_dict[userinfo['user']] = {
|
||||
k: v for k, v in userinfo['state'].items()
|
||||
k: v for k, v in list(userinfo['state'].items())
|
||||
if k in USER_STATE_PUBLIC_KEYS
|
||||
}
|
||||
|
||||
channels_info = {}
|
||||
|
||||
for c_name, c_info in info_result['channels'].items():
|
||||
for c_name, c_info in list(info_result['channels'].items()):
|
||||
if c_name not in include_channel_info:
|
||||
continue
|
||||
connected_list = []
|
||||
|
|
@ -179,9 +180,9 @@ def parse_channels_info(info_result, include_channel_info=None):
|
|||
|
||||
|
||||
def log_filepath(history_location, channel_name):
|
||||
hasher = hashlib.sha256()
|
||||
hasher.update(channel_name.encode('utf8'))
|
||||
filename = '{}.log'.format(hasher.hexdigest())
|
||||
|
||||
channel_hash = ascii_str(sha1_safe(channel_name))
|
||||
filename = f'{channel_hash}.log'
|
||||
filepath = os.path.join(history_location, filename)
|
||||
return filepath
|
||||
|
||||
|
|
@ -226,7 +227,7 @@ def write_history(config, message):
|
|||
|
||||
def get_connection_validators(registry):
|
||||
validators = []
|
||||
for k, config in registry.rhodecode_plugins.items():
|
||||
for k, config in list(registry.rhodecode_plugins.items()):
|
||||
validator = config.get('channelstream', {}).get('connect_validator')
|
||||
if validator:
|
||||
validators.append(validator)
|
||||
|
|
@ -340,7 +341,7 @@ def comment_channelstream_push(request, comment_broadcast_channel, user, msg, **
|
|||
|
||||
comment_data = kwargs.pop('comment_data', {})
|
||||
user_data = kwargs.pop('user_data', {})
|
||||
comment_id = comment_data.keys()[0] if comment_data else ''
|
||||
comment_id = list(comment_data.keys())[0] if comment_data else ''
|
||||
|
||||
message = '<strong>{}</strong> {} #{}'.format(
|
||||
user.username,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue