当前位置: 首页>>代码示例>>Python>>正文


Python logging.Log类代码示例

本文整理汇总了Python中sss.core.logging.Log的典型用法代码示例。如果您正苦于以下问题:Python Log类的具体用法?Python Log怎么用?Python Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setwebrootpermissions

def setwebrootpermissions(self, webroot):
    Log.debug(self, "Setting up permissions")
    try:
        SSSFileUtils.chown(self, webroot, SSSVariables.sss_php_user, SSSVariables.sss_php_user, recursive=True)
    except Exception as e:
        Log.debug(self, str(e))
        raise SiteError("problem occured while setting up webroot permissions")
开发者ID:serversetup,项目名称:SetupServer,代码行数:7,代码来源:site_functions.py

示例2: removeApacheConf

def removeApacheConf(self, domain):
    if os.path.isfile("/etc/apache2/sites-available/{0}.conf".format(domain)):
        Log.debug(self, "Removing Apache configuration")
        SSSFileUtils.rm(self, "/etc/apache2/sites-enabled/{0}.conf".format(domain))
        SSSFileUtils.rm(self, "/etc/apache2/sites-available/{0}.conf".format(domain))
        SSSService.reload_service(self, "apache2")
        SSSGit.add(self, ["/etc/apache2"], msg="Deleted {0} ".format(domain))
开发者ID:serversetup,项目名称:SetupServer,代码行数:7,代码来源:site_functions.py

示例3: secure_auth

 def secure_auth(self):
     """This function Secures authentication"""
     passwd = ''.join([random.choice
                      (string.ascii_letters + string.digits)
                      for n in range(6)])
     if not self.app.pargs.user_input:
         username = input("Provide HTTP authentication user "
                          "name [{0}] :".format(SSSVariables.sss_user))
         self.app.pargs.user_input = username
         if username == "":
             self.app.pargs.user_input = SSSVariables.sss_user
     if not self.app.pargs.user_pass:
         password = getpass.getpass("Provide HTTP authentication "
                                    "password [{0}] :".format(passwd))
         self.app.pargs.user_pass = password
         if password == "":
             self.app.pargs.user_pass = passwd
     Log.debug(self, "printf username:"
               "$(openssl passwd -crypt "
               "password 2> /dev/null)\n\""
               "> /etc/apache2/htpasswd-sss 2>/dev/null")
     SSSShellExec.cmd_exec(self, "printf \"{username}:"
                          "$(openssl passwd -crypt "
                          "{password} 2> /dev/null)\n\""
                          "> /etc/apache2/htpasswd-sss 2>/dev/null"
                          .format(username=self.app.pargs.user_input,
                                  password=self.app.pargs.user_pass),
                          log=False)
     SSSGit.add(self, ["/etc/apache2"],
               msg="Adding changed secure auth into Git")
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:30,代码来源:secure.py

示例4: chown

 def chown(self, path, user, group, recursive=False):
     """
         Change Owner for files
         change owner for file with path specified
         user: username of owner
         group: group of owner
         recursive: if recursive is True change owner for all
                    files in directory
     """
     userid = pwd.getpwnam(user)[2]
     groupid = pwd.getpwnam(user)[3]
     try:
         Log.debug(self, "Changing ownership of {0}, Userid:{1},Groupid:{2}"
                   .format(path, userid, groupid))
         # Change inside files/directory permissions only if recursive flag
         # is set
         if recursive:
             for root, dirs, files in os.walk(path):
                 for d in dirs:
                     os.chown(os.path.join(root, d), userid,
                              groupid)
                 for f in files:
                     os.chown(os.path.join(root, f), userid,
                              groupid)
         os.chown(path, userid, groupid)
     except shutil.Error as e:
         Log.debug(self, "{0}".format(e))
         Log.error(self, "Unable to change owner : {0}".format(path))
     except Exception as e:
         Log.debug(self, "{0}".format(e))
         Log.error(self, "Unable to change owner : {0} ".format(path))
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:31,代码来源:fileutils.py

示例5: add

    def add(self):
        """Swap addition with SimpleSetupServer"""
        if SSSVariables.sss_ram < 512:
            if SSSVariables.sss_swap < 1000:
                Log.info(self, "Adding SWAP file, please wait...")

                # Install dphys-swapfile
                SSSAptGet.update(self)
                SSSAptGet.install(self, ["dphys-swapfile"])
                # Stop service
                SSSShellExec.cmd_exec(self, "service dphys-swapfile stop")
                # Remove Default swap created
                SSSShellExec.cmd_exec(self, "/sbin/dphys-swapfile uninstall")

                # Modify Swap configuration
                if os.path.isfile("/etc/dphys-swapfile"):
                    SSSFileUtils.searchreplace(self, "/etc/dphys-swapfile",
                                              "#CONF_SWAPFILE=/var/swap",
                                              "CONF_SWAPFILE=/sss-swapfile")
                    SSSFileUtils.searchreplace(self,  "/etc/dphys-swapfile",
                                              "#CONF_MAXSWAP=2048",
                                              "CONF_MAXSWAP=1024")
                    SSSFileUtils.searchreplace(self,  "/etc/dphys-swapfile",
                                              "#CONF_SWAPSIZE=",
                                              "CONF_SWAPSIZE=1024")
                else:
                    with open("/etc/dphys-swapfile", 'w') as conffile:
                        conffile.write("CONF_SWAPFILE=/sss-swapfile\n"
                                       "CONF_SWAPSIZE=1024\n"
                                       "CONF_MAXSWAP=1024\n")
                # Create swap file
                SSSShellExec.cmd_exec(self, "service dphys-swapfile start")
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:32,代码来源:addswap.py

示例6: invoke_editor

 def invoke_editor(self, filepath, errormsg=''):
     """
         Open files using sensible editor
     """
     try:
         subprocess.call(['sensible-editor', filepath])
     except OSError as e:
             Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
             raise CommandExecutionError
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:9,代码来源:shellexec.py

示例7: purge

    def purge(self):
        """Start purging of packages"""
        apt_packages = []
        packages = []

        # Default action for stack remove
        if ((not self.app.pargs.web) and (not self.app.pargs.apache2) and
            (not self.app.pargs.php) and (not self.app.pargs.mysql)):
                self.app.pargs.web = True
                self.app.pargs.apache2 = True
                self.app.pargs.php = True
                self.app.pargs.mysql = True

        if self.app.pargs.all:
            self.app.pargs.web = True
            self.app.pargs.apache2 = True
            self.app.pargs.php = True
            self.app.pargs.mysql = True

        if self.app.pargs.web:
            self.app.pargs.apache2 = True
            self.app.pargs.php = True
            self.app.pargs.mysql = True
            #self.app.pargs.wpcli = True
            #self.app.pargs.postfix = True

        if self.app.pargs.apache2:
            Log.debug(self, "Purge apt_packages variable of Apache")
            apt_packages = apt_packages + SSSVariables.sss_apache
        if self.app.pargs.php:
            Log.debug(self, "Purge apt_packages variable PHP")
            apt_packages = apt_packages + SSSVariables.sss_php
        if self.app.pargs.mysql:
            Log.debug(self,"Removing apt_packages variable of PHP")
            apt_packages = apt_packages + SSSVariables.sss_mysql
            packages = packages + ['/usr/bin/tuning-primer']

        if len(packages) or len(apt_packages):
            sss_prompt = input('Are you sure you to want to purge '
                              'from server '
                              'along with their configuration'
                              ' packages,\nAny answer other than '
                              '"yes" will be stop this '
                              'operation :')

            if sss_prompt == 'YES' or sss_prompt == 'yes':
                if len(apt_packages):
                    Log.info(self, "Purging packages, please wait...")
                    SSSAptGet.remove(self, apt_packages, purge=True)
                    SSSAptGet.auto_remove(self)

                if len(packages):
                    SSSFileUtils.remove(self, packages)
                    SSSAptGet.auto_remove(self)

                Log.info(self, "Successfully purged packages")
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:56,代码来源:stack.py

示例8: getAllsites

def getAllsites(self):
    """
        1. returns all records from sss database
    """
    try:
        q = SiteDB.query.all()
        return q
    except Exception as e:
        Log.debug(self, "{0}".format(e))
        Log.error(self, "Unable to query database")
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:10,代码来源:sitedb.py

示例9: callback

 def callback(filename, lines):
     for line in lines:
         if line.find(":::") == -1:
             print(line)
         else:
             data = line.split(":::")
             try:
                 print(data[0], data[1], zlib.decompress(base64.decodestring(data[2])))
             except Exception as e:
                 Log.info(time.time(), "caught exception rendering a new log line in %s" % filename)
开发者ID:serversetup,项目名称:SetupServer,代码行数:10,代码来源:site_functions.py

示例10: getSiteInfo

def getSiteInfo(self, site):
    """
        Retrieves site record from sss databse
    """
    try:
        q = SiteDB.query.filter(SiteDB.sitename == site).first()
        return q
    except Exception as e:
        Log.debug(self, "{0}".format(e))
        Log.error(self, "Unable to query database for site info")
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:10,代码来源:sitedb.py

示例11: check_db_exists

 def check_db_exists(self, db_name):
     try:
         if SSSMysql.dbConnection(self, db_name):
             return True
     except DatabaseNotExistsError as e:
         Log.debug(self, str(e))
         return False
     except MySQLConnectionError as e:
         Log.debug(self, str(e))
         raise MySQLConnectionError
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:10,代码来源:mysql.py

示例12: updateSiteInfo

def updateSiteInfo(self, site, stype='', cache='', webroot='',
                   enabled=True, ssl=False, fs='', db='', db_name=None,
                   db_user=None, db_password=None, db_host=None, hhvm=None,
                   pagespeed=None):
    """updates site record in database"""
    try:
        q = SiteDB.query.filter(SiteDB.sitename == site).first()
    except Exception as e:
        Log.debug(self, "{0}".format(e))
        Log.error(self, "Unable to query database for site info")

    if not q:
        Log.error(self, "{0} does not exist in database".format(site))

    # Check if new record matches old if not then only update database
    if stype and q.site_type != stype:
        q.site_type = stype

    if cache and q.cache_type != cache:
        q.cache_type = cache

    if q.is_enabled != enabled:
        q.is_enabled = enabled

    if ssl and q.is_ssl != ssl:
        q.is_ssl = ssl

    if db_name and q.db_name != db_name:
        q.db_name = db_name

    if db_user and q.db_user != db_user:
        q.db_user = db_user

    if db_user and q.db_password != db_password:
        q.db_password = db_password

    if db_host and q.db_host != db_host:
        q.db_host = db_host

    if webroot and q.site_path != webroot:
        q.site_path = webroot

    if (hhvm is not None) and (q.is_hhvm is not hhvm):
        q.is_hhvm = hhvm

    if (pagespeed is not None) and (q.is_pagespeed is not pagespeed):
        q.is_pagespeed = pagespeed

    try:
        q.created_on = func.now()
        db_session.commit()
    except Exception as e:
        Log.debug(self, "{0}".format(e))
        Log.error(self, "Unable to update site info in application database.")
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:54,代码来源:sitedb.py

示例13: extract

 def extract(self, file, path):
     """Function to extract tar.gz file"""
     try:
         tar = tarfile.open(file)
         tar.extractall(path=path)
         tar.close()
         os.remove(file)
         return True
     except tarfile.TarError as e:
         Log.debug(self, "{0}".format(e))
         Log.error(self, "Unable to extract file \{0}".format(file))
         return False
开发者ID:serversetup,项目名称:SetupServer,代码行数:12,代码来源:extract.py

示例14: isexist

 def isexist(self, path):
     """
         Check if file exist on given path
     """
     try:
         if os.path.exists(path):
             return (True)
         else:
             return (False)
     except OSError as e:
         Log.debug(self, "{0}".format(e.strerror))
         Log.error(self, "Unable to check path {0}".format(path))
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:12,代码来源:fileutils.py

示例15: auto_clean

 def auto_clean(self):
     """
     Similar to `apt-get autoclean`
     """
     try:
         orig_out = sys.stdout
         sys.stdout = open(self.app.config.get("log.logging", "file"), encoding="utf-8", mode="a")
         apt_get.autoclean("-y")
         sys.stdout = orig_out
     except ErrorReturnCode as e:
         Log.debug(self, "{0}".format(e))
         Log.error(self, "Unable to apt-get autoclean")
开发者ID:serversetup,项目名称:SetupServer,代码行数:12,代码来源:aptget.py


注:本文中的sss.core.logging.Log类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。