示例#1
0
def main(port, archive, ip, no_browser, debug):
    if not archive:
        raise ValueError("Empty path provided for archive")

    configure_app(app, archive, debug)

    if not no_browser:
        webbrowser.open("http://{}:{}".format(ip, port))

    app.run(host=ip, port=port)
示例#2
0
def main(port, archive, ip, no_browser, test, debug):
    if not archive:
        raise ValueError("Empty path provided for archive")

    configure_app(app, archive, debug)

    if not no_browser and not test:
        webbrowser.open("http://{}:{}".format(ip, port))

    if not test:
        app.run(host=ip, port=port)

    #download code

    avatar_dir = "avatars"
    if not os.path.exists(avatar_dir):
        os.makedirs(avatar_dir)

    path = extract_archive(archive)

    users = get_users(path)

    sizes = ["24", "32", "48", "72", "192", "512"]
    for size in sizes:
        if not os.path.exists(os.path.join(avatar_dir, size)):
            os.makedirs(os.path.join(avatar_dir, size))

        for user in users:
            url = ""
            if "image_{}".format(size) in users[user]["profile"].keys():
                url = users[user]["profile"]["image_{}".format(size)]
            if url != "":
                filename, file_extension = os.path.splitext(url)
                file_to_save = os.path.join(
                    avatar_dir, size, "{}_{}{}".format(user, size,
                                                       file_extension))
                if not os.path.exists(file_to_save):
                    urllib.request.urlretrieve(url, file_to_save)
                    print("{} {}".format(size, user))

    app1 = flask.Flask(__name__,
                       template_folder="templates",
                       static_folder="static")
    app1.config["SERVER_NAME"] = "test"
    names = ["thelunchers", "secure4questions4dev"]
    channels = get_channels(path)
    for channel_id in channels:
        name = channels[channel_id]["name"]
        #if name == "hadoop":
        #    continue
        print("CHANNEL: {}".format(name))
        with app1.app_context():
            with open("{}.aspx".format(name), 'w', encoding="utf-8") as file:
                file.write(channel_name(name))
示例#3
0
def main(port, archive, ip, no_browser, test, debug, newest_first):
    if not archive:
        raise ValueError("Empty path provided for archive")

    configure_app(app, archive, debug, newest_first)

    if not no_browser and not test:
        webbrowser.open("http://{}:{}".format(ip, port))

    if not test:
        app.run(host=ip, port=port)
示例#4
0
def main(port, archive, ip, no_browser, debug):
    if not archive:
        raise ValueError("Empty path provided for archive")

    configure_app(app, archive, debug)

    if not no_browser:
        webbrowser.open("http://{}:{}".format(ip, port))

    app.run(
        host=ip,
        port=port
    )
示例#5
0
def main(port, archive, ip, no_browser, channels, no_sidebar,
         no_external_references, test, debug):
    if not archive:
        raise ValueError("Empty path provided for archive")

    configure_app(app, archive, channels, no_sidebar, no_external_references,
                  debug)

    if not no_browser and not test:
        webbrowser.open("http://{}:{}".format(ip, port))

    if not test:
        app.run(host=ip, port=port)
示例#6
0
def main(port, archive, ip, no_browser, channels, no_sidebar, no_external_references, test, debug):
    if not archive:
        raise ValueError("Empty path provided for archive")

    configure_app(app, archive, channels, no_sidebar, no_external_references, debug)

    if not no_browser and not test:
        webbrowser.open("http://{}:{}".format(ip, port))

    if not test:
        app.run(
            host=ip,
            port=port
        )
示例#7
0
def main(port, archive, ip, no_browser, channels, no_sidebar,
         no_external_references, test, debug, cache):
    if not archive:
        raise ValueError("Empty path provided for archive")

    if cache:
        os.environ["SLACKVIEWER_TEMP_PATH"] = os.path.join(
            cache, "_slackviewer")
    else:
        os.environ["SLACKVIEWER_TEMP_PATH"] = os.path.join(
            tempfile.gettempdir(), "_slackviewer")

    configure_app(app, archive, channels, no_sidebar, no_external_references,
                  debug)

    if not no_browser and not test:
        webbrowser.open("http://{}:{}".format(ip, port))

    if not test:
        app.run(host=ip, port=port)
示例#8
0
def main(port, archive, ip, no_browser=False, debug=False):
    if not archive:
        raise ValueError("Empty path provided for archive")

    configure_app(app, archive, debug)

    if not no_browser:
        webbrowser.open("http://{}:{}".format(ip, port))

    # Combine all the PDFs
    from PyPDF2 import PdfFileWriter, PdfFileReader

    # Creating a routine that appends files to the output file
    def append_pdf(input, output):
        [
            output.addPage(input.getPage(page_num))
            for page_num in range(input.numPages)
        ]

    # Creating an object where pdf pages are appended to
    output = PdfFileWriter()

    # First append the cover page
    append_pdf(PdfFileReader(open("report_src/cover.pdf", "rb")), output)
    # Then append the graphs for report
    append_pdf(PdfFileReader(open("report_src/report_graphs.pdf", "rb")),
               output)
    for file in os.listdir('report_src'):
        if file.endswith(
                '.pdf'
        ) and 'report_graphs' not in file and 'cover.pdf' not in file:
            append_pdf(PdfFileReader(open('report_src/' + file, "rb")), output)
    # Writing all the collected pages to a file
    output.write(open("Your_Report.pdf", "wb"))

    app.run(host=ip, port=port)
示例#9
0
from slackviewer.app import app as application
from slackviewer.archive import extract_archive
from slackviewer.reader import Reader
from slackviewer.appconfig import set_env_params

import os

try:
    from flask import _app_ctx_stack as stack
except ImportError:
    from flask import _request_ctx_stack as stack

set_env_params()

path = extract_archive(os.environ.get("SEV_ARCHIVE"))
reader = Reader(path)
stack.channels = reader.compile_channels(os.environ.get("SEV_CHANNELS", None))
stack.groups = reader.compile_groups()
stack.dms = reader.compile_dm_messages()
stack.dm_users = reader.compile_dm_users()
stack.mpims = reader.compile_mpim_messages()
stack.mpim_users = reader.compile_mpim_users()

if __name__ == '__main__':
    if not application.is_test:
        application.run(host=os.environ.get("SEV_IP", '0.0.0.0'),
                        port=os.environ.get("SEV_PORT", 5000))
示例#10
0
def main():
    debug = _configure_app()
    app.run(host="0.0.0.0", debug=debug)