# Path: nuka/utils.py
# PY3 = sys.version_info[0] == 3
# ARCHIVE_EXTS = ('.gz', '.tar', '.zip')
# LOG = 60
# CHANGED = logging.WARNING + 1
# PROGRESS = logging.WARNING + 2
#     def next(o):
# def default_watcher(delay=5):
#     def watcher(task, process):
# def import_module(name):
# def makedirs(dirname, mod=None, own=None):
# def chmod(dst, mod, recursive=False):
# def chown(dst, own, recursive=False):
# def best_executable():
# def isexecutable(path):
#     def __init__(self, value, alphabet=None, length=16):
#     def iterator(self):
#     def next(self):
# def proto_dumps(data, content_type=u'plain'):
# def proto_dumps_std(data, std, content_type='plain'):
# def proto_dumps_std_threadsafe(data, std):
# def proto_loads_std(std):
# class secret(object):
# 
# Path: nuka/task.py
# class teardown(SetupTask):
#     """remove `remote_dir` from the host"""
# 
#     teardown_cmd = '{0}rm -Rf {1[remote_dir]}'
# 
#     def __init__(self, host):
#         host._cancelled = False
#         super().__init__(host=host)
# 
#     def __class_name__(self):
#         return 'teardown'
# 
#     async def run(self):
#         if not self.host.failed():
#             sudo = self.host.use_sudo and 'sudo ' or ''
#             cmd = self.teardown_cmd.format(sudo, config)
#             await self.host.run_command(cmd, task=self)


import os
import sys
import jinja2
import nuka
from uuid import uuid4
from operator import itemgetter
from collections import defaultdict
from nuka.utils import json
from nuka.task import teardown
    from wsgiref.simple_server import make_server
    with open(filename, 'w') as fd:
        fd.write(dumped_data)

    ctx = dict(
        data=data,
        dumped_data=dumped_data,
    )

    filename = os.path.join(dirname, '{0}_gantt.html'.format(report_name))
    template = engine.get_template('reports/gantt.html.j2')
    with open(filename, 'w') as fd:
        fd.write(template.render(ctx))

    filename = os.path.join(dirname, '{0}_stats.html'.format(report_name))
    template = engine.get_template('reports/stats.html.j2')
    with open(filename, 'w') as fd:
        fd.write(template.render(ctx))


def run_dev_server():  # pragma: no cover
    """Usage: python -m nuka.report <type> <data_filename>"""
    engine = nuka.config.get_template_engine()
    type, filename = sys.argv[-2:]

    def app(environ, start_response):
        start_response('200 OK',
                       [('Content-Type', 'text/html; charset=utf8')])
        template = engine.get_template('reports/{0}.html.j2'.format(type))
        with open(filename) as fd:
            data = json.load(fd)

# Path: nuka/utils.py
# PY3 = sys.version_info[0] == 3
# ARCHIVE_EXTS = ('.gz', '.tar', '.zip')
# LOG = 60
# CHANGED = logging.WARNING + 1
# PROGRESS = logging.WARNING + 2
#     def next(o):
# def default_watcher(delay=5):
#     def watcher(task, process):
# def import_module(name):
# def makedirs(dirname, mod=None, own=None):
# def chmod(dst, mod, recursive=False):
# def chown(dst, own, recursive=False):
# def best_executable():
# def isexecutable(path):
#     def __init__(self, value, alphabet=None, length=16):
#     def iterator(self):
#     def next(self):
# def proto_dumps(data, content_type=u'plain'):
# def proto_dumps_std(data, std, content_type='plain'):
# def proto_dumps_std_threadsafe(data, std):
# def proto_loads_std(std):
# class secret(object):
# 
# Path: nuka/task.py
# class teardown(SetupTask):
#     """remove `remote_dir` from the host"""
# 
#     teardown_cmd = '{0}rm -Rf {1[remote_dir]}'
# 
#     def __init__(self, host):
#         host._cancelled = False
#         super().__init__(host=host)
# 
#     def __class_name__(self):
#         return 'teardown'
# 
#     async def run(self):
#         if not self.host.failed():
#             sudo = self.host.use_sudo and 'sudo ' or ''
#             cmd = self.teardown_cmd.format(sudo, config)
#             await self.host.run_command(cmd, task=self)


# Path: nuka/reports.py
import os
import sys
import jinja2
import nuka
from uuid import uuid4
from operator import itemgetter
from collections import defaultdict
from nuka.utils import json
from nuka.task import teardown
    from wsgiref.simple_server import make_server

    with open(filename, 'w') as fd:
        fd.write(dumped_data)

    ctx = dict(
        data=data,
        dumped_data=dumped_data,
    )

    filename = os.path.join(dirname, '{0}_gantt.html'.format(report_name))
    template = engine.get_template('reports/gantt.html.j2')
    with open(filename, 'w') as fd:
        fd.write(template.render(ctx))

    filename = os.path.join(dirname, '{0}_stats.html'.format(report_name))
    template = engine.get_template('reports/stats.html.j2')
    with open(filename, 'w') as fd:
        fd.write(template.render(ctx))


def run_dev_server():  # pragma: no cover
    """Usage: python -m nuka.report <type> <data_filename>"""
    engine = nuka.config.get_template_engine()
    type, filename = sys.argv[-2:]

    def app(environ, start_response):
        start_response('200 OK',
                       [('Content-Type', 'text/html; charset=utf8')])
        template = engine.get_template('reports/{0}.html.j2'.format(type))
        with open(filename) as fd:
            data = json.load(fd)

        html = template.render(dict(data=data, dumped_data=json.dumps(data)))