# Path: pyanaconda/flags.py
# class Flags(object):
# class BootArgs(OrderedDict):
#     def __setattr__(self, attr, val):
#     def get(self, attr, val=None):
#     def set_cmdline_bool(self, flag):
#     def __init__(self, read_cmdline=True):
#     def read_cmdline(self):
#     def __init__(self, cmdline=None, files=None):
#     def read(self, filenames):
#     def readstr(self, cmdline):
#     def getbool(self, arg, default=False):
# def can_touch_runtime_system(msg, touch_live=False):
# 
# Path: pyanaconda/constants.py
# DRACUT_SHUTDOWN_EJECT = "/run/initramfs/usr/lib/dracut/hooks/shutdown/99anaconda-eject.sh"
# 
# ROOT_PATH = "/mnt/sysimage"
# 
# TRANSLATIONS_UPDATE_DIR="/tmp/updates/po"
# 
# UNSUPPORTED_HW = 1 << 28
# 
# Path: pyanaconda/anaconda_log.py
# DEFAULT_TTY_LEVEL = logging.INFO
# ENTRY_FORMAT = "%(asctime)s,%(msecs)03d %(levelname)s %(name)s: %(message)s"
# TTY_FORMAT = "%(levelname)s %(name)s: %(message)s"
# STDOUT_FORMAT = "%(asctime)s %(message)s"
# DATE_FORMAT = "%H:%M:%S"
# MAIN_LOG_FILE = "/tmp/anaconda.log"
# MAIN_LOG_TTY = "/dev/tty3"
# PROGRAM_LOG_FILE = "/tmp/program.log"
# PROGRAM_LOG_TTY = "/dev/tty5"
# STORAGE_LOG_FILE = "/tmp/storage.log"
# PACKAGING_LOG_FILE = "/tmp/packaging.log"
# SENSITIVE_INFO_LOG_FILE = "/tmp/sensitive-info.log"
# ANACONDA_SYSLOG_FACILITY = SysLogHandler.LOG_LOCAL1
#     SYSLOG_CFGFILE  = "/etc/rsyslog.conf"
#     VIRTIO_PORT = "/dev/virtio-ports/org.fedoraproject.anaconda.log.0"
#         TEMPLATE = "*.* @@%s\n"
#         TEMPLATE = "*.* %s;anaconda_syslog\n"
# def autoSetLevel(handler, value):
# def setHandlersLevel(logr, level):
#     def __init__(self,
#                  address=('localhost', SYSLOG_UDP_PORT),
#                  facility=SysLogHandler.LOG_USER,
#                  tag=''):
#     def emit(self, record):
#     def __init__ (self):
#     def addFileHandler (self, dest, addToLogger, minLevel=DEFAULT_TTY_LEVEL,
#                         fmtStr=ENTRY_FORMAT,
#                         autoLevel=False):
#     def forwardToSyslog(self, logr):
#     def showwarning(self, message, category, filename, lineno,
#                       file=sys.stderr, line=None):
#     def restartSyslog(self):
#     def updateRemote(self, remote_syslog):
#     def setupVirtio(self):
# def init():
# class AnacondaSyslogHandler(SysLogHandler):
# class AnacondaLog:


import glob
import os
import stat
import os.path
import errno
import subprocess
import unicodedata
import string
import types
import logging
from threading import Thread
from Queue import Queue, Empty
from pyanaconda.flags import flags
from pyanaconda.constants import DRACUT_SHUTDOWN_EJECT, ROOT_PATH, TRANSLATIONS_UPDATE_DIR, UNSUPPORTED_HW
from pyanaconda.regexes import PROXY_URL_PARSE
from pyanaconda.anaconda_log import program_log_lock

def resetRpmDb():
    for rpmfile in glob.glob("%s/var/lib/rpm/__db.*" % ROOT_PATH):
        try:
            os.unlink(rpmfile)
        except OSError as e:
            log.debug("error %s removing file: %s", e, rpmfile)

def parseNfsUrl(nfsurl):
    options = ''
    host = ''
    path = ''
    if nfsurl:
        s = nfsurl.split(":")
        s.pop(0)
        if len(s) >= 3:
            (options, host, path) = s[:3]
        elif len(s) == 2:
            (host, path) = s
        else:
            host = s[0]

    return (options, host, path)

def add_po_path(module, directory):
    """ Looks to see what translations are under a given path and tells
    the gettext module to use that path as the base dir """
    for d in os.listdir(directory):
        if not os.path.isdir("%s/%s" %(directory,d)):
            continue

# Path: pyanaconda/flags.py
# class Flags(object):
# class BootArgs(OrderedDict):
#     def __setattr__(self, attr, val):
#     def get(self, attr, val=None):
#     def set_cmdline_bool(self, flag):
#     def __init__(self, read_cmdline=True):
#     def read_cmdline(self):
#     def __init__(self, cmdline=None, files=None):
#     def read(self, filenames):
#     def readstr(self, cmdline):
#     def getbool(self, arg, default=False):
# def can_touch_runtime_system(msg, touch_live=False):
# 
# Path: pyanaconda/constants.py
# DRACUT_SHUTDOWN_EJECT = "/run/initramfs/usr/lib/dracut/hooks/shutdown/99anaconda-eject.sh"
# 
# ROOT_PATH = "/mnt/sysimage"
# 
# TRANSLATIONS_UPDATE_DIR="/tmp/updates/po"
# 
# UNSUPPORTED_HW = 1 << 28
# 
# Path: pyanaconda/anaconda_log.py
# DEFAULT_TTY_LEVEL = logging.INFO
# ENTRY_FORMAT = "%(asctime)s,%(msecs)03d %(levelname)s %(name)s: %(message)s"
# TTY_FORMAT = "%(levelname)s %(name)s: %(message)s"
# STDOUT_FORMAT = "%(asctime)s %(message)s"
# DATE_FORMAT = "%H:%M:%S"
# MAIN_LOG_FILE = "/tmp/anaconda.log"
# MAIN_LOG_TTY = "/dev/tty3"
# PROGRAM_LOG_FILE = "/tmp/program.log"
# PROGRAM_LOG_TTY = "/dev/tty5"
# STORAGE_LOG_FILE = "/tmp/storage.log"
# PACKAGING_LOG_FILE = "/tmp/packaging.log"
# SENSITIVE_INFO_LOG_FILE = "/tmp/sensitive-info.log"
# ANACONDA_SYSLOG_FACILITY = SysLogHandler.LOG_LOCAL1
#     SYSLOG_CFGFILE  = "/etc/rsyslog.conf"
#     VIRTIO_PORT = "/dev/virtio-ports/org.fedoraproject.anaconda.log.0"
#         TEMPLATE = "*.* @@%s\n"
#         TEMPLATE = "*.* %s;anaconda_syslog\n"
# def autoSetLevel(handler, value):
# def setHandlersLevel(logr, level):
#     def __init__(self,
#                  address=('localhost', SYSLOG_UDP_PORT),
#                  facility=SysLogHandler.LOG_USER,
#                  tag=''):
#     def emit(self, record):
#     def __init__ (self):
#     def addFileHandler (self, dest, addToLogger, minLevel=DEFAULT_TTY_LEVEL,
#                         fmtStr=ENTRY_FORMAT,
#                         autoLevel=False):
#     def forwardToSyslog(self, logr):
#     def showwarning(self, message, category, filename, lineno,
#                       file=sys.stderr, line=None):
#     def restartSyslog(self):
#     def updateRemote(self, remote_syslog):
#     def setupVirtio(self):
# def init():
# class AnacondaSyslogHandler(SysLogHandler):
# class AnacondaLog:


# Path: pyanaconda/iutil.py
import glob
import os
import stat
import os.path
import errno
import subprocess
import unicodedata
import string
import types
import logging
from threading import Thread
from Queue import Queue, Empty
from pyanaconda.flags import flags
from pyanaconda.constants import DRACUT_SHUTDOWN_EJECT, ROOT_PATH, TRANSLATIONS_UPDATE_DIR, UNSUPPORTED_HW
from pyanaconda.regexes import PROXY_URL_PARSE
from pyanaconda.anaconda_log import program_log_lock


def resetRpmDb():
    for rpmfile in glob.glob("%s/var/lib/rpm/__db.*" % ROOT_PATH):
        try:
            os.unlink(rpmfile)
        except OSError as e:
            log.debug("error %s removing file: %s", e, rpmfile)

def parseNfsUrl(nfsurl):
    options = ''
    host = ''
    path = ''
    if nfsurl:
        s = nfsurl.split(":")
        s.pop(0)
        if len(s) >= 3:
            (options, host, path) = s[:3]
        elif len(s) == 2:
            (host, path) = s
        else:
            host = s[0]

    return (options, host, path)

def add_po_path(module, directory):
    """ Looks to see what translations are under a given path and tells
    the gettext module to use that path as the base dir """
    for d in os.listdir(directory):
        if not os.path.isdir("%s/%s" %(directory,d)):
            continue

        if not os.path.exists("%s/%s/LC_MESSAGES" %(directory,d)):