Exemplo n.º 1
0
# -*- coding: utf-8 -*-
"""Contains wp-cli calling and parsing classes / methods"""
import os
import getpass
import subprocess
import json
from datetime import datetime
from threading import Thread
from random import randint
from logmod import Log

L = Log()


class Installations(object):
    """Class used for obtaining installation dir and details"""
    def __init__(self, app):
        self.app = app
        L.debug('Installations Initialized')
        self.username = getpass.getuser()
        self.homedir = os.path.expanduser('~%s' % self.username)
        self.app.state.homedir = self.homedir
        self.app.state.temp_dir = os.path.join(self.homedir, 'wpuitmp')
        if not os.path.isdir(self.app.state.temp_dir):
            os.mkdir(self.app.state.temp_dir)
        L.debug("Homedir: %s", self.homedir)
        self.installations = self.get_installation_dirs()
        if self.installations:
            self.get_installation_details()
            L.debug("WP Installation for user %s: %s", self.username,
                    self.installations)
Exemplo n.º 2
0
#!/usr/bin/python3
"""Main application module"""
# -*- coding: utf-8 -*-
import os
import sys
import tempfile

from datetime import datetime
from application import App
from settings import Settings
from widgets import CustomWidgets
from logmod import Log
W = CustomWidgets()
L = Log()
S = Settings()
PYTHONIOENCODING = "utf-8"
sys.excepthook = L.handle_exception
L.info("\n****\nApplication Started at %s \n\n****\n",
       datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S.%f"))


def main():
    """Starts main loop"""
    S.app['home_dir'] = os.path.expanduser("~")
    tempfile.tempdir = S.app['home_dir']
    temporary_directory = tempfile.TemporaryDirectory()
    S.app['temp_dir'] = temporary_directory
    L.debug('temp_dir: %s', S.app['temp_dir'])

    app = App(S)
    L.debug('AppInstance: %s', app)