Exemplo n.º 1
0
def close_log(path):
    """
    Prints a nice message to file saying the log has been closed.

    :param path: Path to file.
    :return:
    """
    _ = Translations().get()

    path = path.replace("..", "")
    path = "logs/" + path
    if not os.path.exists(os.path.dirname(path)):
        return

    logger = logging.getLogger("Logging")

    logger.propagate = False

    handler = logging.FileHandler(path)
    formatter = logging.Formatter(
        "%(asctime)s | %(name)25s | %(levelname)8s | %(message)s")
    formatter.datefmt = "%d %b %Y - %H:%M:%S"
    handler.setFormatter(formatter)
    handler.setLevel(_globals["level"])
    logger.addHandler(handler)

    logger.info(_("*** LOGFILE CLOSED: %s ***\n\n") % path)
    logger.removeHandler(handler)

    del handler
    del logger
Exemplo n.º 2
0
from plugins.web.stats import Stats

from system.command_manager import CommandManager
from system.event_manager import EventManager
from system.plugins.manager import PluginManager
from system.plugins.plugin import PluginObject
from system.storage.formats import YAML, JSON
from system.storage.manager import StorageManager
from system.translations import Translations

from twisted.internet import reactor

from utils.packages.packages import Packages
from utils.password import mkpasswd

_ = Translations().get()
__ = Translations().get_m()


class WebPlugin(PluginObject):
    """
    Web plugin object
    """

    api_log = None
    api_keys = None

    api_key_data = {}
    config = {}
    data = {}
Exemplo n.º 3
0
# coding=utf-8

from twisted.internet import protocol

from system.decorators.log import deprecated
from system.logging.logger import getLogger
from system.translations import Translations

__author__ = "Gareth Coles"
_ = Translations().get()


class Protocol(protocol.Protocol):
    """
    Base class for building protocols.

    You'll /HAVE/ to subclass this in some form or any protocols you make will
    be invalid without it.

    This class provides several methods that must be uniform across all
    protocols. The reason for this is mostly so plugins that are agnostic
    towards protocols can still work with every protocol the bot is using.

    If you need to inherit another base class (for example irc.IRCClient),
    then use multiple inheritance, with the other base class first.

    For example::

        class Protocol(irc.IRCClient, generic.protocol.Protocol):
            pass
Exemplo n.º 4
0
operations = ["install", "update", "uninstall", "list", "list-installed",
              "info", "setup"]
if __name__ == "__main__":
    p = argparse.ArgumentParser(description=DESC)
    p.add_argument("-l", "--language", help="Specify which language to use")
    p.add_argument(
        "-ow",
        "--overwrite",
        action="store_true",
        help="Overwrite already-installed packages"
    )
    p.add_argument("operation", help="Specify what to do.", choices=operations)
    p.add_argument("target", nargs="?", default=None)

    args = p.parse_args()
    trans = Translations(args.language, log=False)
else:
    trans = Translations(log=False)

_ = trans.get()

import tempfile
import urllib

try:
    import pip
except ImportError:
    url = "https://raw.github.com/pypa/pip/master/contrib/get-pip.py"
    print _("Installing pip..")
    print ""
    r = urllib.urlopen(url)
Exemplo n.º 5
0
                    "Takes a hostname as an argument. This requires you to "
                    "have pycharm-debug.egg in your Python PATH. If you don't "
                    "know what this means, then you don't need to use this.")
p.add_argument("-nu", "--no-upgrade",
               help="Disable the automatic in-virtualenv update run every"
                    "time the bot starts up in a virtualenv or pyenv",
               action="store_true")
p.add_argument(
    "-d", "--debug", help="Force-enable debug logging", action="store_true"
)
p.add_argument(
    "-t", "--trace", help="Force-enable trace logging", action="store_true"
)

args = p.parse_args()
trans = Translations(args.language, args.mlanguage)

if args.pycharm_remote_debug:
    import pydevd
    pydevd.settrace(
        args.pycharm_remote_debug, port=20202,
        stdoutToServer=True, stderrToServer=True
    )

_ = trans.get()


def is_virtualenv():
    if hasattr(sys, "real_prefix"):
        return True  # Virtualenv
Exemplo n.º 6
0
operations = ["install", "update", "uninstall", "list", "list-installed",
              "info", "setup"]
if __name__ == "__main__":
    p = argparse.ArgumentParser(description=DESC)
    p.add_argument("-l", "--language", help="Specify which language to use")
    p.add_argument(
        "-ow",
        "--overwrite",
        action="store_true",
        help="Overwrite already-installed packages"
    )
    p.add_argument("operation", help="Specify what to do.", choices=operations)
    p.add_argument("target", nargs="?", default=None)

    args = p.parse_args()
    trans = Translations(args.language, log=False)
else:
    trans = Translations(log=False)

_ = trans.get()

import tempfile
import urllib

try:
    import pip
except ImportError:
    url = "https://raw.github.com/pypa/pip/master/contrib/get-pip.py"
    print(_("Installing pip.."))
    print("")
    r = urllib.urlopen(url)