Skip to content

Commit f25c58b

Browse files
committed
change syntax to make it compatible with python 3
1 parent 3176111 commit f25c58b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+301
-299
lines changed

doc/conf.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@
5050
master_doc = 'index'
5151

5252
# General information about the project.
53-
project = u'HubbleStack'
54-
copyright = u'2018, Colton Myers, Christer Edwards'
55-
author = u'Colton Myers, Christer Edwards'
53+
project = 'HubbleStack'
54+
copyright = '2018, Colton Myers, Christer Edwards'
55+
author = 'Colton Myers, Christer Edwards'
5656

5757
# The version info for the project you're documenting, acts as replacement for
5858
# |version| and |release|, also used in various other places throughout the
5959
# built documents.
6060
#
6161
# The short X.Y version.
62-
version = u'3.0.7'
62+
version = '3.0.7'
6363
# The full version, including alpha/beta/rc tags.
64-
release = u'3.0.7-1'
64+
release = '3.0.7-1'
6565

6666
# The language for content autogenerated by Sphinx. Refer to documentation
6767
# for a list of supported languages.
@@ -140,8 +140,8 @@
140140
# (source start file, target name, title,
141141
# author, documentclass [howto, manual, or own class]).
142142
latex_documents = [
143-
(master_doc, 'HubbleStack.tex', u'HubbleStack Documentation',
144-
u'Colton Myers, Christer Edwards', 'manual'),
143+
(master_doc, 'HubbleStack.tex', 'HubbleStack Documentation',
144+
'Colton Myers, Christer Edwards', 'manual'),
145145
]
146146

147147

@@ -150,7 +150,7 @@
150150
# One entry per manual page. List of tuples
151151
# (source start file, name, description, authors, manual section).
152152
man_pages = [
153-
(master_doc, 'hubblestack', u'HubbleStack Documentation',
153+
(master_doc, 'hubblestack', 'HubbleStack Documentation',
154154
[author], 1)
155155
]
156156

@@ -161,7 +161,7 @@
161161
# (source start file, target name, title, author,
162162
# dir menu entry, description, category)
163163
texinfo_documents = [
164-
(master_doc, 'HubbleStack', u'HubbleStack Documentation',
164+
(master_doc, 'HubbleStack', 'HubbleStack Documentation',
165165
author, 'HubbleStack', 'One line description of project.',
166166
'Miscellaneous'),
167167
]

hubblestack/daemon.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66

7-
from __future__ import print_function
7+
88

99
# import lockfile
1010
import argparse
@@ -310,7 +310,7 @@ def schedule():
310310
schedule_config = __opts__.get('schedule', {})
311311
if 'user_schedule' in __opts__ and isinstance(__opts__['user_schedule'], dict):
312312
schedule_config.update(__opts__['user_schedule'])
313-
for jobname, jobdata in schedule_config.iteritems():
313+
for jobname, jobdata in schedule_config.items():
314314
# Error handling galore
315315
if not jobdata or not isinstance(jobdata, dict):
316316
log.error('Scheduled job {0} does not have valid data'.format(jobname))
@@ -813,7 +813,7 @@ def emit_to_syslog(grains_to_emit):
813813
for grain in grains_to_emit:
814814
if grain in __grains__:
815815
if bool(__grains__[grain]) and isinstance(__grains__[grain], dict):
816-
for key, value in __grains__[grain].iteritems():
816+
for key, value in __grains__[grain].items():
817817
syslog_list.append('{0}={1}'.format(key, value))
818818
else:
819819
syslog_list.append('{0}={1}'.format(grain, __grains__[grain]))

hubblestack/extmods/audit/grep.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
True/False. Whether to use multiline flag for regex matching with
4343
match_output_regex set to True. Defaults to True.
4444
"""
45-
from __future__ import absolute_import
45+
4646

4747
import logging
4848
import os

hubblestack/extmods/fdg/curl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
a system, we don't want an attacker to be able to send that data to arbitrary
1414
endpoints.
1515
"""
16-
from __future__ import absolute_import
16+
1717
import logging
1818
import requests
1919

hubblestack/extmods/fdg/grep.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
This fdg module allows for grepping against files and strings
77
"""
8-
from __future__ import absolute_import
8+
99
import logging
1010
import os.path
1111

hubblestack/extmods/fdg/osquery.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
This fdg module allows for running osquery queries
77
"""
8-
from __future__ import absolute_import
8+
99
import json
1010
import logging
1111
import os
@@ -91,8 +91,8 @@ def _osquery(query_sql, osquery_path=None, args=None):
9191
if res['retcode'] == 0:
9292
ret = json.loads(res['stdout'])
9393
for result in ret:
94-
for key, value in result.iteritems():
95-
if value and isinstance(value, basestring) and value.startswith('__JSONIFY__'):
94+
for key, value in result.items():
95+
if value and isinstance(value, str) and value.startswith('__JSONIFY__'):
9696
result[key] = json.loads(value[len('__JSONIFY__'):])
9797
return True, ret
9898
return False, res['stdout']

hubblestack/extmods/fdg/process.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
This module primarily processes and properly format
77
the data outputted by a module to serve it to another module.
88
"""
9-
from __future__ import absolute_import
9+
1010

1111
import logging
1212
import re
@@ -72,9 +72,9 @@ def _filter_dict(dct,
7272
not equal to 2.
7373
"""
7474
ret = dct
75-
for comp, value in filter_rules.iteritems():
75+
for comp, value in filter_rules.items():
7676
try:
77-
ret = {key: val for key, val in ret.iteritems()
77+
ret = {key: val for key, val in ret.items()
7878
if (filter_values and _compare(comp, val, value)) or
7979
(not filter_values and _compare(comp, key, value))}
8080
except ArgumentValueError:
@@ -174,7 +174,7 @@ def _filter(seq,
174174
LOG.error("``filter_rules`` should be of type dict")
175175
return None
176176
ret = seq
177-
for comp, value in filter_rules.iteritems():
177+
for comp, value in filter_rules.items():
178178
try:
179179
ret = [x for x in ret if _compare(comp, x, value)]
180180
except ArgumentValueError:
@@ -428,7 +428,7 @@ def dict_to_list(starting_dict=None, update_chained=True, chained=None, chained_
428428
except (AttributeError, ValueError, TypeError):
429429
LOG.error("Invalid arguments type.", exc_info=True)
430430
return False, None
431-
ret = [(key, value) for key, value in chained.iteritems()]
431+
ret = [(key, value) for key, value in chained.items()]
432432
status = bool(ret)
433433

434434
return status, ret
@@ -482,7 +482,7 @@ def _dict_convert_none(dictionary):
482482
LOG.error("Invalid argument type - should be dict")
483483
return None
484484
updated_dict = {}
485-
for key, value in dictionary.iteritems():
485+
for key, value in dictionary.items():
486486
if value == '':
487487
updated_dict[key] = None
488488
elif isinstance(value, dict):
@@ -594,7 +594,7 @@ def _sterilize_dict(dictionary):
594594
LOG.error("Invalid argument type - should be dict")
595595
return None
596596
updated_dict = {}
597-
for key, value in dictionary.iteritems():
597+
for key, value in dictionary.items():
598598
if isinstance(value, dict):
599599
updated_dict[key] = _sterilize_dict(value)
600600
elif isinstance(value, (set, list, tuple)):

hubblestack/extmods/fdg/process_status.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
processes, with various options for filtering
77
"""
88

9-
from __future__ import absolute_import
9+
1010
import logging
1111

1212

@@ -45,7 +45,7 @@ def _convert_to_str(process_data):
4545
ret = []
4646
try:
4747
for process in process_data:
48-
str_process = {str(name): str(val) for name, val in process.iteritems()}
48+
str_process = {str(name): str(val) for name, val in process.items()}
4949
ret.append(str_process)
5050
except (TypeError, AttributeError):
5151
LOG.error('Invalid argument type; must be list of dicts.', exc_info=True)

hubblestack/extmods/fdg/readfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
This fdg module allows for reading in the contents of files, with various
66
options for format and filtering.
77
"""
8-
from __future__ import absolute_import
8+
99

1010
import json as _json
1111
import logging

hubblestack/extmods/fdg/time_sync.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
NTP servers for differences bigger than 15 minutes.
66
'''
77

8-
from __future__ import absolute_import
8+
99
import logging
1010
import salt.utils.platform
1111

hubblestack/extmods/fileserver/azurefs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"""
4848

4949
# Import python libs
50-
from __future__ import absolute_import
50+
5151
from distutils.version import LooseVersion
5252
import base64
5353
import json

hubblestack/extmods/fileserver/s3fs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"""
8080

8181
# Import python libs
82-
from __future__ import absolute_import, print_function, unicode_literals
82+
8383
import datetime
8484
import os
8585
import time
@@ -683,7 +683,7 @@ def _get_file():
683683
path_style=s3_key_kwargs['path_style'],
684684
https_enable=s3_key_kwargs['https_enable'])
685685
if ret:
686-
for header_name, header_value in ret['headers'].items():
686+
for header_name, header_value in list(ret['headers'].items()):
687687
header_name = header_name.strip()
688688
header_value = header_value.strip()
689689
if six.text_type(header_name).lower() == 'last-modified':

hubblestack/extmods/grains/cloud_details.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _get_aws_details():
6666
r = requests.get('http://169.254.169.254/latest/meta-data/local-hostname', timeout=3, proxies=proxies)
6767
if r.status_code == requests.codes.ok:
6868
aws_extra['cloud_private_hostname'] = r.text
69-
for key in aws_extra.keys():
69+
for key in list(aws_extra.keys()):
7070
if not aws_extra[key]:
7171
aws_extra.pop(key)
7272

@@ -123,7 +123,7 @@ def _get_azure_details():
123123
grain_name_mac = "cloud_interface_{0}_mac_address".format(counter)
124124
azure_extra[grain_name_mac] = value['macAddress']
125125

126-
for key in azure_extra.keys():
126+
for key in list(azure_extra.keys()):
127127
if not azure_extra[key]:
128128
azure_extra.pop(key)
129129

@@ -194,7 +194,7 @@ def _get_gcp_details():
194194
external_ips_list = [ item['externalIp'] for item in value['accessConfigs'] if 'externalIp' in item ]
195195
gcp_extra[grain_name_accessconfig_external_ips] = ','.join(external_ips_list)
196196

197-
for key in gcp_extra.keys():
197+
for key in list(gcp_extra.keys()):
198198
if not gcp_extra[key]:
199199
gcp_extra.pop(key)
200200

hubblestack/extmods/grains/configgrains.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def configgrains():
4343

4444
grains_to_make = __salt__['config.get']('config_to_grains', default=[])
4545
for grain in grains_to_make:
46-
for k, v in grain.iteritems():
46+
for k, v in grain.items():
4747
grain_value = __salt__['config.get'](v, default=None)
4848
if grain_value:
4949
grains[k] = grain_value

hubblestack/extmods/grains/default_gw.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ip6_gw: True # True/False if default ipv6 gateway
1616
ip_gw: True # True if either of the above is True, False otherwise
1717
"""
18-
from __future__ import absolute_import
18+
1919

2020
import logging
2121

hubblestack/extmods/grains/fqdn.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def dest_ip():
5252
# Fallback to "best guess"
5353
filtered_interfaces = {}
5454
# filter out empty, lo, and docker0
55-
for interface, ips in interfaces.iteritems():
55+
for interface, ips in interfaces.items():
5656
if not ips:
5757
continue
5858
if interface in ('lo', 'docker0'):
@@ -64,13 +64,13 @@ def dest_ip():
6464
if ip != '127.0.0.1':
6565
return {'local_ip4': ip}
6666
# Use .*0 if present
67-
for interface, ips in filtered_interfaces.iteritems():
67+
for interface, ips in filtered_interfaces.items():
6868
if '0' in interface:
6969
for ip in ips:
7070
if ip != '127.0.0.1':
7171
return {'local_ip4': ip}
7272
# Use whatever isn't 127.0.0.1
73-
for interface, ips in filtered_interfaces.iteritems():
73+
for interface, ips in filtered_interfaces.items():
7474
for ip in ips:
7575
if ip != '127.0.0.1':
7676
return {'local_ip4': ip}

hubblestack/extmods/modules/audit.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
it was a success or a failure, and ``data_dict`` is a dictionary of any
9595
information that should be added to the check's data dictionary in the return.
9696
"""
97-
from __future__ import absolute_import
97+
9898

9999
import fnmatch
100100
import logging
@@ -197,7 +197,7 @@ def audit(audit_files=None,
197197
succinct_ret = {'Success': [],
198198
'Failure': [],
199199
'Skipped': []}
200-
for success_type, checks in ret.iteritems():
200+
for success_type, checks in ret.items():
201201
for check in checks:
202202
succinct_ret[success_type].append({check['tag']: check.get('description', '<no description>')})
203203

@@ -278,7 +278,7 @@ def _get_top_data(topfile):
278278

279279
ret = []
280280

281-
for match, data in topdata.iteritems():
281+
for match, data in topdata.items():
282282
if __salt__['match.compound'](match):
283283
ret.extend(data)
284284

@@ -348,10 +348,10 @@ def _run_audit(ret, audit_data, tags, labels, audit_file):
348348
:return:
349349
Returns the updated ``ret`` object
350350
"""
351-
for audit_id, data in audit_data.iteritems():
351+
for audit_id, data in audit_data.items():
352352
LOG.debug('Executing audit id {0} in audit file {1}'.format(audit_id, audit_file))
353353
try:
354-
module = data.keys()[0]
354+
module = list(data.keys())[0]
355355
data = data[module]
356356
if not isinstance(data, dict):
357357
LOG.error('Audit data with id {0} from file {1} not formatted '

hubblestack/extmods/modules/conf_publisher.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _filter_config(opts_to_log, remove_dots=True):
6363
patterns_to_filter = ["password", "token", "passphrase", "privkey", "keyid", "s3.key"]
6464
filtered_conf = _remove_sensitive_info(opts_to_log, patterns_to_filter)
6565
if remove_dots:
66-
for key in filtered_conf.keys():
66+
for key in list(filtered_conf.keys()):
6767
if '.' in key:
6868
filtered_conf[key.replace('.', '_')] = filtered_conf.pop(key)
6969
return filtered_conf
@@ -76,7 +76,7 @@ def _remove_sensitive_info(obj, patterns_to_filter):
7676
if isinstance(obj, dict):
7777
obj = {
7878
key: _remove_sensitive_info(value, patterns_to_filter)
79-
for key, value in obj.iteritems()
79+
for key, value in obj.items()
8080
if not any(patt in key for patt in patterns_to_filter)}
8181
elif isinstance(obj, list):
8282
obj = [_remove_sensitive_info(item, patterns_to_filter) for item in obj]

0 commit comments

Comments
 (0)