##// END OF EJS Templates
channelstream: python3 fixes
super-admin -
r5003:c1b8a600 default
parent child Browse files
Show More
@@ -19,7 +19,6 b''
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 import os
22 import hashlib
23 22 import itsdangerous
24 23 import logging
25 24 import requests
@@ -32,6 +31,8 b' import rhodecode.lib.helpers as h'
32 31 from rhodecode.lib.auth import HasRepoPermissionAny
33 32 from rhodecode.lib.ext_json import json
34 33 from rhodecode.model.db import User
34 from rhodecode.lib.str_utils import ascii_str
35 from rhodecode.lib.hash_utils import sha1_safe
35 36
36 37 log = logging.getLogger(__name__)
37 38
@@ -157,13 +158,13 b' def parse_channels_info(info_result, inc'
157 158 user_state_dict = {}
158 159 for userinfo in info_result['users']:
159 160 user_state_dict[userinfo['user']] = {
160 k: v for k, v in userinfo['state'].items()
161 k: v for k, v in list(userinfo['state'].items())
161 162 if k in USER_STATE_PUBLIC_KEYS
162 163 }
163 164
164 165 channels_info = {}
165 166
166 for c_name, c_info in info_result['channels'].items():
167 for c_name, c_info in list(info_result['channels'].items()):
167 168 if c_name not in include_channel_info:
168 169 continue
169 170 connected_list = []
@@ -179,9 +180,9 b' def parse_channels_info(info_result, inc'
179 180
180 181
181 182 def log_filepath(history_location, channel_name):
182 hasher = hashlib.sha256()
183 hasher.update(channel_name.encode('utf8'))
184 filename = '{}.log'.format(hasher.hexdigest())
183
184 channel_hash = ascii_str(sha1_safe(channel_name))
185 filename = f'{channel_hash}.log'
185 186 filepath = os.path.join(history_location, filename)
186 187 return filepath
187 188
@@ -226,7 +227,7 b' def write_history(config, message):'
226 227
227 228 def get_connection_validators(registry):
228 229 validators = []
229 for k, config in registry.rhodecode_plugins.items():
230 for k, config in list(registry.rhodecode_plugins.items()):
230 231 validator = config.get('channelstream', {}).get('connect_validator')
231 232 if validator:
232 233 validators.append(validator)
@@ -340,7 +341,7 b' def comment_channelstream_push(request, '
340 341
341 342 comment_data = kwargs.pop('comment_data', {})
342 343 user_data = kwargs.pop('user_data', {})
343 comment_id = comment_data.keys()[0] if comment_data else ''
344 comment_id = list(comment_data.keys())[0] if comment_data else ''
344 345
345 346 message = '<strong>{}</strong> {} #{}'.format(
346 347 user.username,
General Comments 0
You need to be logged in to leave comments. Login now