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


Python Log.error方法代码示例

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


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

示例1: chown

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
 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,代码行数:33,代码来源:fileutils.py

示例2: dist_upgrade

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
    def dist_upgrade(self):
        """
        Similar to `apt-get upgrade`
        """
        try:
            with open("/var/log/sss/sss.log", "a") as f:
                proc = subprocess.Popen(
                    "DEBIAN_FRONTEND=noninteractive "
                    "apt-get dist-upgrade -o "
                    'Dpkg::Options::="--force-confdef"'
                    " -o "
                    'Dpkg::Options::="--force-confold"'
                    " -y ",
                    shell=True,
                    stdin=None,
                    stdout=f,
                    stderr=f,
                    executable="/bin/bash",
                )
                proc.wait()

            if proc.returncode == 0:
                return True
            else:
                Log.info(self, Log.FAIL + "Oops Something went " "wrong!!")
                Log.error(self, "Check logs for reason " "`tail /var/log/ss/ss.log` & Try Again!!!")
        except Exception as e:
            Log.error(self, "Error while installing packages, " "apt-get exited with error")
开发者ID:serversetup,项目名称:SetupServer,代码行数:30,代码来源:aptget.py

示例3: remove

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
    def remove(self, packages, auto=False, purge=False):
        all_packages = " ".join(packages)
        try:
            with open("/var/log/sss/sss.log", "a") as f:
                if purge:
                    proc = subprocess.Popen(
                        "apt-get purge -y {0}".format(all_packages),
                        shell=True,
                        stdin=None,
                        stdout=f,
                        stderr=f,
                        executable="/bin/bash",
                    )
                else:
                    proc = subprocess.Popen(
                        "apt-get remove -y {0}".format(all_packages),
                        shell=True,
                        stdin=None,
                        stdout=f,
                        stderr=f,
                        executable="/bin/bash",
                    )
                proc.wait()
            if proc.returncode == 0:
                return True
            else:
                Log.info(self, Log.FAIL + "Oops Something went " "wrong!!")
                Log.error(self, "Check logs for reason " "`tail /var/log/sss/sss.log` & Try Again!!!")

        except Exception as e:
            Log.error(self, "Error while installing packages, " "apt-get exited with error")
开发者ID:serversetup,项目名称:SetupServer,代码行数:33,代码来源:aptget.py

示例4: reload_service

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
    def reload_service(self, service_name):
        """
            Stop service
            Similar to `service xyz stop`
        """
        try:
            if service_name in ['php5-fpm']:
                service_cmd = ('{0} -t && service {0} reload'
                               .format(service_name))
            else:
                service_cmd = ('service {0} reload'.format(service_name))

            Log.info(self, "Reload : {0:10}".format(service_name), end='')
            retcode = subprocess.getstatusoutput(service_cmd)
            if retcode[0] == 0:
                    Log.info(self, "[" + Log.ENDC + "OK" + Log.OKGREEN + "]")
                    return True
            else:
                Log.debug(self, "{0}".format(retcode[1]))
                Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKGREEN+"]")
                return False
        except OSError as e:
            Log.debug(self, "{0}".format(e))
            Log.error(self, "\nFailed to reload service {0}"
                      .format(service_name))
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:27,代码来源:services.py

示例5: install

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
    def install(self, packages):
        all_packages = " ".join(packages)
        try:
            with open("/var/log/sss/sss.log", "a") as f:
                proc = subprocess.Popen(
                    "DEBIAN_FRONTEND=noninteractive "
                    "apt-get install -o "
                    'Dpkg::Options::="--force-confdef"'
                    " -o "
                    'Dpkg::Options::="--force-confold"'
                    " -y {0}".format(all_packages),
                    shell=True,
                    stdin=None,
                    stdout=f,
                    stderr=f,
                    executable="/bin/bash",
                )
                proc.wait()

            if proc.returncode == 0:
                return True
            else:
                Log.info(self, Log.FAIL + "Oops Something went " "wrong!!")
                Log.error(self, "Check logs for reason " "`tail /var/log/sss/sss.log` & Try Again!!!")

        except Exception as e:
            Log.info(self, Log.FAIL + "Oops Something went " "wrong!!")
            Log.error(self, "Check logs for reason " "`tail /var/log/sss/sss.log` & Try Again!!!")
开发者ID:serversetup,项目名称:SetupServer,代码行数:30,代码来源:aptget.py

示例6: remove

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
    def remove(self, ppa=None, repo_url=None):
        """
        This function used to remove ppa's
        If ppa is provided adds repo file to
            /etc/apt/sources.list.d/
        command.
        """
        if ppa:
            SSSShellExec.cmd_exec(self, "add-apt-repository -y "
                                 "--remove '{ppa_name}'"
                                 .format(ppa_name=ppa))
        elif repo_url:
            repo_file_path = ("/etc/apt/sources.list.d/"
                              + SSSVariables().sss_repo_file)

            try:
                repofile = open(repo_file_path, "w+")
                repofile.write(repofile.read().replace(repo_url, ""))
                repofile.close()
            except IOError as e:
                Log.debug(self, "{0}".format(e))
                Log.error(self, "File I/O error.")
            except Exception as e:
                Log.debug(self, "{0}".format(e))
                Log.error(self, "Unable to remove repo")
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:27,代码来源:apt_repo.py

示例7: add

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
 def add(self, paths, msg="Intializating"):
     """
         Initializes Directory as repository if not already git repo.
         and adds uncommited changes automatically
     """
     for path in paths:
         global git
         git = git.bake("--git-dir={0}/.git".format(path), "--work-tree={0}".format(path))
         if os.path.isdir(path):
             if not os.path.isdir(path + "/.git"):
                 try:
                     Log.debug(self, "SSS Git: git init at {0}".format(path))
                     git.init(path)
                 except ErrorReturnCode as e:
                     Log.debug(self, "{0}".format(e))
                     Log.error(self, "Unable to git init at {0}".format(path))
             status = git.status("-s")
             if len(status.splitlines()) > 0:
                 try:
                     Log.debug(self, "SSS Git: git commit at {0}".format(path))
                     git.add("--all")
                     git.commit("-am {0}".format(msg))
                 except ErrorReturnCode as e:
                     Log.debug(self, "{0}".format(e))
                     Log.error(self, "Unable to git commit at {0} ".format(path))
         else:
             Log.debug(self, "SSS Git: Path {0} not present".format(path))
开发者ID:serversetup,项目名称:SetupServer,代码行数:29,代码来源:git.py

示例8: deleteDB

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
def deleteDB(self, dbname, dbuser, dbhost, exit=True):
    try:
        # Check if Database exists
        try:
            if SSSMysql.check_db_exists(self, dbname):
                # Drop database if exists
                Log.debug(self, "dropping database `{0}`".format(dbname))
                SSSMysql.execute(self,
                                "drop database `{0}`".format(dbname),
                                errormsg='Unable to drop database {0}'
                                .format(dbname))
        except StatementExcecutionError as e:
            Log.debug(self, "drop database failed")
            Log.info(self, "Database {0} not dropped".format(dbname))

        except MySQLConnectionError as e:
            Log.debug(self, "Mysql Connection problem occured")

        if dbuser != 'root':
            Log.debug(self, "dropping user `{0}`".format(dbuser))
            try:
                SSSMysql.execute(self,
                                "drop user `{0}`@`{1}`"
                                .format(dbuser, dbhost))
            except StatementExcecutionError as e:
                Log.debug(self, "drop database user failed")
                Log.info(self, "Database {0} not dropped".format(dbuser))
            try:
                SSSMysql.execute(self, "flush privileges")
            except StatementExcecutionError as e:
                Log.debug(self, "drop database failed")
                Log.info(self, "Database {0} not dropped".format(dbname))
    except Exception as e:
        Log.error(self, "Error occured while deleting database", exit)
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:36,代码来源:site_functions.py

示例9: remove_symlink

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
 def remove_symlink(self, filepath):
     """
         Removes symbolic link for the path provided with filepath
     """
     try:
         Log.debug(self, "Removing symbolic link: {0}".format(filepath))
         os.unlink(filepath)
     except Exception as e:
         Log.debug(self, "{0}".format(e))
         Log.error(self, "Unable to reomove symbolic link ...\n")
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:12,代码来源:fileutils.py

示例10: getAllsites

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
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,代码行数:12,代码来源:sitedb.py

示例11: getSiteInfo

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
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,代码行数:12,代码来源:sitedb.py

示例12: auto_remove

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
 def auto_remove(self):
     """
     Similar to `apt-get autoremove`
     """
     try:
         Log.debug(self, "Running apt-get autoremove")
         apt_get.autoremove("-y")
     except ErrorReturnCode as e:
         Log.debug(self, "{0}".format(e))
         Log.error(self, "Unable to apt-get autoremove")
开发者ID:serversetup,项目名称:SetupServer,代码行数:12,代码来源:aptget.py

示例13: isexist

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
 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,代码行数:14,代码来源:fileutils.py

示例14: auto_clean

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
 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,代码行数:14,代码来源:aptget.py

示例15: extract

# 需要导入模块: from sss.core.logging import Log [as 别名]
# 或者: from sss.core.logging.Log import error [as 别名]
 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,代码行数:14,代码来源:extract.py


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