Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change syntax to make it compatible with python 3 #732

Merged
merged 3 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@
master_doc = 'index'

# General information about the project.
project = u'HubbleStack'
copyright = u'2018, Colton Myers, Christer Edwards'
author = u'Colton Myers, Christer Edwards'
project = 'HubbleStack'
copyright = '2018, Colton Myers, Christer Edwards'
author = 'Colton Myers, Christer Edwards'

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

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


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

Expand All @@ -161,7 +161,7 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'HubbleStack', u'HubbleStack Documentation',
(master_doc, 'HubbleStack', 'HubbleStack Documentation',
author, 'HubbleStack', 'One line description of project.',
'Miscellaneous'),
]
Expand Down
19 changes: 10 additions & 9 deletions hubblestack/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""


from __future__ import print_function


# import lockfile
import argparse
Expand Down Expand Up @@ -310,7 +310,7 @@ def schedule():
schedule_config = __opts__.get('schedule', {})
if 'user_schedule' in __opts__ and isinstance(__opts__['user_schedule'], dict):
schedule_config.update(__opts__['user_schedule'])
for jobname, jobdata in schedule_config.iteritems():
for jobname, jobdata in schedule_config.items():
# Error handling galore
if not jobdata or not isinstance(jobdata, dict):
log.error('Scheduled job {0} does not have valid data'.format(jobname))
Expand Down Expand Up @@ -556,12 +556,13 @@ def load_config():
if __opts__['daemonize']:
__opts__['log_level'] = 'info'
# Handle the explicit -vvv settings
if __opts__['verbose'] == 1:
__opts__['log_level'] = 'warning'
elif __opts__['verbose'] == 2:
__opts__['log_level'] = 'info'
elif __opts__['verbose'] >= 3:
__opts__['log_level'] = 'debug'
if __opts__['verbose']:
if __opts__['verbose'] == 1:
__opts__['log_level'] = 'warning'
elif __opts__['verbose'] == 2:
__opts__['log_level'] = 'info'
elif __opts__['verbose'] >= 3:
__opts__['log_level'] = 'debug'

# Setup module/grain/returner dirs
module_dirs = __opts__.get('module_dirs', [])
Expand Down Expand Up @@ -813,7 +814,7 @@ def emit_to_syslog(grains_to_emit):
for grain in grains_to_emit:
if grain in __grains__:
if bool(__grains__[grain]) and isinstance(__grains__[grain], dict):
for key, value in __grains__[grain].iteritems():
for key, value in __grains__[grain].items():
syslog_list.append('{0}={1}'.format(key, value))
else:
syslog_list.append('{0}={1}'.format(grain, __grains__[grain]))
Expand Down
2 changes: 1 addition & 1 deletion hubblestack/extmods/audit/grep.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
True/False. Whether to use multiline flag for regex matching with
match_output_regex set to True. Defaults to True.
"""
from __future__ import absolute_import


import logging
import os
Expand Down
2 changes: 1 addition & 1 deletion hubblestack/extmods/fdg/curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
a system, we don't want an attacker to be able to send that data to arbitrary
endpoints.
"""
from __future__ import absolute_import

import logging
import requests

Expand Down
2 changes: 1 addition & 1 deletion hubblestack/extmods/fdg/grep.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

This fdg module allows for grepping against files and strings
"""
from __future__ import absolute_import

import logging
import os.path

Expand Down
6 changes: 3 additions & 3 deletions hubblestack/extmods/fdg/osquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

This fdg module allows for running osquery queries
"""
from __future__ import absolute_import

import json
import logging
import os
Expand Down Expand Up @@ -91,8 +91,8 @@ def _osquery(query_sql, osquery_path=None, args=None):
if res['retcode'] == 0:
ret = json.loads(res['stdout'])
for result in ret:
for key, value in result.iteritems():
if value and isinstance(value, basestring) and value.startswith('__JSONIFY__'):
for key, value in result.items():
if value and isinstance(value, str) and value.startswith('__JSONIFY__'):
result[key] = json.loads(value[len('__JSONIFY__'):])
return True, ret
return False, res['stdout']
14 changes: 7 additions & 7 deletions hubblestack/extmods/fdg/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
This module primarily processes and properly format
the data outputted by a module to serve it to another module.
"""
from __future__ import absolute_import


import logging
import re
Expand Down Expand Up @@ -72,9 +72,9 @@ def _filter_dict(dct,
not equal to 2.
"""
ret = dct
for comp, value in filter_rules.iteritems():
for comp, value in filter_rules.items():
try:
ret = {key: val for key, val in ret.iteritems()
ret = {key: val for key, val in ret.items()
if (filter_values and _compare(comp, val, value)) or
(not filter_values and _compare(comp, key, value))}
except ArgumentValueError:
Expand Down Expand Up @@ -174,7 +174,7 @@ def _filter(seq,
LOG.error("``filter_rules`` should be of type dict")
return None
ret = seq
for comp, value in filter_rules.iteritems():
for comp, value in filter_rules.items():
try:
ret = [x for x in ret if _compare(comp, x, value)]
except ArgumentValueError:
Expand Down Expand Up @@ -428,7 +428,7 @@ def dict_to_list(starting_dict=None, update_chained=True, chained=None, chained_
except (AttributeError, ValueError, TypeError):
LOG.error("Invalid arguments type.", exc_info=True)
return False, None
ret = [(key, value) for key, value in chained.iteritems()]
ret = [(key, value) for key, value in chained.items()]
status = bool(ret)

return status, ret
Expand Down Expand Up @@ -482,7 +482,7 @@ def _dict_convert_none(dictionary):
LOG.error("Invalid argument type - should be dict")
return None
updated_dict = {}
for key, value in dictionary.iteritems():
for key, value in dictionary.items():
if value == '':
updated_dict[key] = None
elif isinstance(value, dict):
Expand Down Expand Up @@ -594,7 +594,7 @@ def _sterilize_dict(dictionary):
LOG.error("Invalid argument type - should be dict")
return None
updated_dict = {}
for key, value in dictionary.iteritems():
for key, value in dictionary.items():
if isinstance(value, dict):
updated_dict[key] = _sterilize_dict(value)
elif isinstance(value, (set, list, tuple)):
Expand Down
4 changes: 2 additions & 2 deletions hubblestack/extmods/fdg/process_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
processes, with various options for filtering
"""

from __future__ import absolute_import

import logging


Expand Down Expand Up @@ -45,7 +45,7 @@ def _convert_to_str(process_data):
ret = []
try:
for process in process_data:
str_process = {str(name): str(val) for name, val in process.iteritems()}
str_process = {str(name): str(val) for name, val in process.items()}
ret.append(str_process)
except (TypeError, AttributeError):
LOG.error('Invalid argument type; must be list of dicts.', exc_info=True)
Expand Down
2 changes: 1 addition & 1 deletion hubblestack/extmods/fdg/readfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
This fdg module allows for reading in the contents of files, with various
options for format and filtering.
"""
from __future__ import absolute_import


import json as _json
import logging
Expand Down
2 changes: 1 addition & 1 deletion hubblestack/extmods/fdg/time_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
NTP servers for differences bigger than 15 minutes.
'''

from __future__ import absolute_import

import logging
import salt.utils.platform

Expand Down
2 changes: 1 addition & 1 deletion hubblestack/extmods/fileserver/azurefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"""

# Import python libs
from __future__ import absolute_import

from distutils.version import LooseVersion
import base64
import json
Expand Down
2 changes: 1 addition & 1 deletion hubblestack/extmods/fileserver/s3fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"""

# Import python libs
from __future__ import absolute_import, print_function, unicode_literals

import datetime
import os
import time
Expand Down
Loading