本文整理汇总了Python中sss.core.logging.Log类的典型用法代码示例。如果您正苦于以下问题:Python Log类的具体用法?Python Log怎么用?Python Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Log类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: remove
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,代码行数:25,代码来源:apt_repo.py
示例17: install
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,代码行数:28,代码来源:aptget.py
示例18: connect
def connect(self):
"""Makes connection with MySQL server"""
try:
if os.path.exists('/etc/mysql/conf.d/my.cnf'):
connection = pymysql.connect(read_default_file='/etc/mysql/conf.d/my.cnf')
else:
connection = pymysql.connect(read_default_file='~/.my.cnf')
return connection
except ValueError as e:
Log.debug(self, str(e))
raise MySQLConnectionError
except pymysql.err.InternalError as e:
Log.debug(self, str(e))
raise MySQLConnectionError
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:14,代码来源:mysql.py
示例19: addNewSite
def addNewSite(self, site, stype, cache, path,
enabled=True, ssl=False, fs='ext4', db='mysql',
db_name=None, db_user=None, db_password=None,
db_host='localhost', hhvm=0, pagespeed=0):
"""
Add New Site record information into sss database.
"""
try:
newRec = SiteDB(site, stype, cache, path, enabled, ssl, fs, db,
db_name, db_user, db_password, db_host, hhvm,
pagespeed)
db_session.add(newRec)
db_session.commit()
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to add site to database")
开发者ID:harshiljethava,项目名称:TestingSimpleSetupServer,代码行数:16,代码来源:sitedb.py
示例20: default
def default(self):
if not self.app.pargs.mariadb:
self.app.args.print_help()
if self.app.pargs.mariadb:
if SSSVariables.sss_mysql_host is not "localhost":
Log.error(self, "Remote MySQL found, EasyEngine will not " "install MariaDB")
if SSSShellExec.cmd_exec(self, "mysqladmin ping") and (not SSSAptGet.is_installed(self, "mariadb-server")):
Log.info(self, "If your database size is big, " "migration may take some time.")
Log.info(self, "During migration non Apache parts of " "your site may remain down")
start_migrate = input('Type "mariadb" to continue:')
if start_migrate != "mariadb":
Log.error(self, "Not starting migration")
self.migrate_mariadb()
else:
Log.error(self, "Your current MySQL is not alive or " "you allready installed MariaDB")
开发者ID:serversetup,项目名称:SetupServer,代码行数:17,代码来源:stack_migrate.py
注:本文中的sss.core.logging.Log类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论