Skip to content

Commit 4cef888

Browse files
authored
Merge pull request #732 from Tenebriso/python3
change syntax to make it compatible with python 3
2 parents 3176111 + e866068 commit 4cef888

Some content is hidden

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

76 files changed

+375
-332
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

+10-9
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))
@@ -556,12 +556,13 @@ def load_config():
556556
if __opts__['daemonize']:
557557
__opts__['log_level'] = 'info'
558558
# Handle the explicit -vvv settings
559-
if __opts__['verbose'] == 1:
560-
__opts__['log_level'] = 'warning'
561-
elif __opts__['verbose'] == 2:
562-
__opts__['log_level'] = 'info'
563-
elif __opts__['verbose'] >= 3:
564-
__opts__['log_level'] = 'debug'
559+
if __opts__['verbose']:
560+
if __opts__['verbose'] == 1:
561+
__opts__['log_level'] = 'warning'
562+
elif __opts__['verbose'] == 2:
563+
__opts__['log_level'] = 'info'
564+
elif __opts__['verbose'] >= 3:
565+
__opts__['log_level'] = 'debug'
565566

566567
# Setup module/grain/returner dirs
567568
module_dirs = __opts__.get('module_dirs', [])
@@ -813,7 +814,7 @@ def emit_to_syslog(grains_to_emit):
813814
for grain in grains_to_emit:
814815
if grain in __grains__:
815816
if bool(__grains__[grain]) and isinstance(__grains__[grain], dict):
816-
for key, value in __grains__[grain].iteritems():
817+
for key, value in __grains__[grain].items():
817818
syslog_list.append('{0}={1}'.format(key, value))
818819
else:
819820
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

+1-1
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

0 commit comments

Comments
 (0)