本文整理汇总了Python中public.readFile函数的典型用法代码示例。如果您正苦于以下问题:Python readFile函数的具体用法?Python readFile怎么用?Python readFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readFile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: SetDataDir
def SetDataDir(self,get):
if get.datadir[-1] == '/': get.datadir = get.datadir[0:-1];
if os.path.exists(get.datadir): os.system('mkdir -p ' + get.datadir);
mysqlInfo = self.GetMySQLInfo(get);
if mysqlInfo['datadir'] == get.datadir: return public.returnMsg(False,'DATABASE_MOVE_RE');
os.system('/etc/init.d/mysqld stop');
os.system('\cp -a -r ' + mysqlInfo['datadir'] + '/* ' + get.datadir + '/');
os.system('chown -R mysql.mysql ' + get.datadir);
os.system('chmod -R 755 ' + get.datadir);
os.system('rm -f ' + get.datadir + '/*.pid');
os.system('rm -f ' + get.datadir + '/*.err');
public.CheckMyCnf();
myfile = '/etc/my.cnf';
mycnf = public.readFile(myfile);
public.writeFile('/etc/my_backup.cnf',mycnf);
mycnf = mycnf.replace(mysqlInfo['datadir'],get.datadir);
public.writeFile(myfile,mycnf);
os.system('/etc/init.d/mysqld start');
result = public.ExecShell('/etc/init.d/mysqld status');
if result[0].find('SUCCESS') != -1:
public.writeFile('data/datadir.pl',get.datadir);
return public.returnMsg(True,'DATABASE_MOVE_SUCCESS');
else:
os.system('pkill -9 mysqld');
public.writeFile(myfile,public.readFile('/etc/my_backup.cnf'));
os.system('/etc/init.d/mysqld start');
return public.returnMsg(False,'DATABASE_MOVE_ERR');
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:29,代码来源:database.py
示例2: errorNum
def errorNum(self,s = True):
numFile = '/tmp/panelNum.pl';
timeFile = '/tmp/panelNime.pl';
if os.path.exists(timeFile):
stime = float(public.readFile(timeFile));
etime = time.time() - stime;
if etime < 1800: return False;
os.remove(timeFile);
os.remove(numFile);
if not os.path.exists(numFile):
public.writeFile(numFile,'0');
public.ExecShell('chmod 600 ' + numFile);
num = int(public.readFile(numFile));
if s:
num +=1;
public.writeFile(numFile,str(num));
if num > 3:
web.ctx.session.code = True;
if num > 12:
public.writeFile(timeFile,str(time.time()));
public.ExecShell('chmod 600 ' + timeFile);
return False;
return True;
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:28,代码来源:main.py
示例3: GetSystemVersion
def GetSystemVersion(self):
version = public.readFile('/etc/redhat-release')
if not version:
version = public.readFile('/etc/issue').replace('\\n \\l','').strip();
else:
version = version.replace('release ','').strip();
return version
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:7,代码来源:score_main.py
示例4: GetPHPConfig
def GetPHPConfig(self,version):
import re
setupPath = web.ctx.session.setupPath;
file = setupPath + "/php/"+version+"/etc/php.ini"
phpini = public.readFile(file)
file = setupPath + "/php/"+version+"/etc/php-fpm.conf"
phpfpm = public.readFile(file)
data = {}
try:
rep = "upload_max_filesize\s*=\s*([0-9]+)M"
tmp = re.search(rep,phpini).groups()
data['max'] = tmp[0]
except:
data['max'] = '50'
try:
rep = "request_terminate_timeout\s*=\s*([0-9]+)\n"
tmp = re.search(rep,phpfpm).groups()
data['maxTime'] = tmp[0]
except:
data['maxTime'] = 0
try:
rep = ur"\n;*\s*cgi\.fix_pathinfo\s*=\s*([0-9]+)\s*\n"
tmp = re.search(rep,phpini).groups()
if tmp[0] == '1':
data['pathinfo'] = True
else:
data['pathinfo'] = False
except:
data['pathinfo'] = False
return data
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:33,代码来源:panelPlugin.py
示例5: limitAddress
def limitAddress(self,type):
import time
logFile = 'data/'+web.ctx.ip+'.login';
timeFile = 'data/'+web.ctx.ip+'_time.login';
limit = 6;
outtime = 600;
try:
#初始化
if not os.path.exists(timeFile): public.writeFile(timeFile,str(time.time()));
if not os.path.exists(logFile): public.writeFile(logFile,'0');
#判断是否解除登陆限制
time1 = float(public.readFile(timeFile));
if (time.time() - time1) > outtime:
public.writeFile(logFile,'0');
public.writeFile(timeFile,str(time.time()));
#计数
num1 = int(public.readFile(logFile));
if type == '+':
num1 += 1;
public.writeFile(logFile,str(num1));
self.errorNum();
web.ctx.session.code = True;
return limit - num1;
#清空
if type == '-':
public.ExecShell('rm -f data/*.login');
web.ctx.session.code = False;
return 1;
return limit - num1;
except:
return limit;
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:34,代码来源:main.py
示例6: get_phpmyadmin_dir
def get_phpmyadmin_dir(self):
path = web.ctx.session.setupPath + '/phpmyadmin'
if not os.path.exists(path): return None
phpport = '888';
try:
import re;
if web.ctx.session.webserver == 'nginx':
filename = web.ctx.session.setupPath + '/nginx/conf/nginx.conf';
conf = public.readFile(filename);
rep = "listen\s+([0-9]+)\s*;";
rtmp = re.search(rep,conf);
if rtmp:
phpport = rtmp.groups()[0];
else:
filename = web.ctx.session.setupPath + '/apache/conf/extra/httpd-vhosts.conf';
conf = public.readFile(filename);
rep = "Listen\s+([0-9]+)\s*\n";
rtmp = re.search(rep,conf);
if rtmp:
phpport = rtmp.groups()[0];
except:
pass
for filename in os.listdir(path):
print filename
filepath = path + '/' + filename
if os.path.isdir(filepath):
if filename[0:10] == 'phpmyadmin':
return str(filename),phpport
return None
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:32,代码来源:main.py
示例7: setPHPMaxSize
def setPHPMaxSize(self,get):
version = get.version
max = get.max
if int(max) < 2: return public.returnMsg(False,'PHP_UPLOAD_MAX_ERR')
#设置PHP
path = web.ctx.session.setupPath+'/php/'+version+'/etc/php.ini'
conf = public.readFile(path)
rep = u"\nupload_max_filesize\s*=\s*[0-9]+M"
conf = re.sub(rep,u'\nupload_max_filesize = '+max+'M',conf)
rep = u"\npost_max_size\s*=\s*[0-9]+M"
conf = re.sub(rep,u'\npost_max_size = '+max+'M',conf)
public.writeFile(path,conf)
if public.get_webserver() == 'nginx':
#设置Nginx
path = web.ctx.session.setupPath+'/nginx/conf/nginx.conf'
conf = public.readFile(path)
rep = "client_max_body_size\s+([0-9]+)m"
tmp = re.search(rep,conf).groups()
if int(tmp[0]) < int(max):
conf = re.sub(rep,'client_max_body_size '+max+'m',conf)
public.writeFile(path,conf)
public.serviceReload()
public.phpReload(version);
public.WriteLog("TYPE_PHP", "PHP_UPLOAD_MAX",(version,max))
return public.returnMsg(True,'SET_SUCCESS')
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:29,代码来源:config.py
示例8: setPathInfo
def setPathInfo(self,get):
#设置PATH_INFO
version = get.version
type = get.type
if public.get_webserver() == 'nginx':
path = web.ctx.session.setupPath+'/nginx/conf/enable-php-'+version+'.conf';
conf = public.readFile(path);
rep = "\s+#*include\s+pathinfo.conf;";
if type == 'on':
conf = re.sub(rep,'\n\t\t\tinclude pathinfo.conf;',conf)
else:
conf = re.sub(rep,'\n\t\t\t#include pathinfo.conf;',conf)
public.writeFile(path,conf)
public.serviceReload();
path = web.ctx.session.setupPath+'/php/'+version+'/etc/php.ini';
conf = public.readFile(path);
rep = "\n*\s*cgi\.fix_pathinfo\s*=\s*([0-9]+)\s*\n";
status = '0'
if type == 'on':status = '1'
conf = re.sub(rep,"\ncgi.fix_pathinfo = "+status+"\n",conf)
public.writeFile(path,conf)
public.WriteLog("TYPE_PHP", "PHP_PATHINFO_SUCCESS",(version,type));
public.phpReload(version);
return public.returnMsg(True,'SET_SUCCESS');
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:25,代码来源:config.py
示例9: __Conn
def __Conn(self):
try:
import public
try:
import MySQLdb
except Exception,ex:
self.__DB_ERR = ex
return False;
try:
myconf = public.readFile('/etc/my.cnf');
rep = "port\s*=\s*([0-9]+)"
self.__DB_PORT = int(re.search(rep,myconf).groups()[0]);
except:
self.__DB_PORT = 3306;
self.__DB_PASS = public.M('config').where('id=?',(1,)).getField('mysql_root');
try:
if os.path.exists(self.__DB_HOST_CONF): self.__DB_HOST = public.readFile(self.__DB_HOST_CONF);
self.__DB_CONN = MySQLdb.connect(host = self.__DB_HOST,user = self.__DB_USER,passwd = self.__DB_PASS,port = self.__DB_PORT,charset="utf8",connect_timeout=1)
except MySQLdb.Error,e:
if e[0] != 2003:
self.__DB_ERR = e
return False
if self.__DB_HOST == 'localhost':
self.__DB_HOST = '127.0.0.1';
else:
self.__DB_HOST = 'localhost';
public.writeFile(self.__DB_HOST_CONF,self.__DB_HOST);
self.__DB_CONN = MySQLdb.connect(host = self.__DB_HOST,user = self.__DB_USER,passwd = self.__DB_PASS,port = self.__DB_PORT,charset="utf8",connect_timeout=1)
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:28,代码来源:panelMysql.py
示例10: GetSoftList
def GetSoftList(self,get):
#取软件列表
import json,os,web
tmp = public.readFile('data/softList.conf');
data = json.loads(tmp)
tasks = public.M('tasks').where("status!=?",('1',)).field('status,name').select()
for i in range(len(data)):
data[i]['check'] = web.ctx.session.rootPath+'/'+data[i]['check'];
for n in range(len(data[i]['versions'])):
#处理任务标记
isTask = '1';
for task in tasks:
tmp = public.getStrBetween('[',']',task['name'])
if not tmp:continue;
tmp1 = tmp.split('-');
if data[i]['name'] == 'PHP':
if tmp1[0].lower() == data[i]['name'].lower() and tmp1[1] == data[i]['versions'][n]['version']: isTask = task['status'];
else:
if tmp1[0].lower() == data[i]['name'].lower(): isTask = task['status'];
#检查安装状态
if data[i]['name'] == 'PHP':
data[i]['versions'][n]['task'] = isTask
checkFile = data[i]['check'].replace('VERSION',data[i]['versions'][n]['version'].replace('.',''));
else:
data[i]['task'] = isTask
version = public.readFile(web.ctx.session.rootPath+'/server/'+data[i]['name'].lower()+'/version.pl');
if not version:continue;
if version.find(data[i]['versions'][n]['version']) == -1:continue;
checkFile = data[i]['check'];
data[i]['versions'][n]['status'] = os.path.exists(checkFile);
return data
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:32,代码来源:ajax.py
示例11: checkWebType
def checkWebType(self):
if os.path.exists(self.setupPath + '/nginx'):
web.ctx.session.webserver = 'nginx'
else:
web.ctx.session.webserver = 'apache'
if os.path.exists(self.setupPath+'/'+web.ctx.session.webserver+'/version.pl'):
web.ctx.session.webversion = public.readFile(self.setupPath+'/'+web.ctx.session.webserver+'/version.pl').strip()
filename = self.setupPath+'/data/phpmyadminDirName.pl'
if os.path.exists(filename):
web.ctx.session.phpmyadminDir = public.readFile(filename).strip()
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:10,代码来源:common.py
示例12: GetOS
def GetOS(self):
if not hasattr(web.ctx.session,'server_os'):
tmp = {}
if os.path.exists('/etc/redhat-release'):
tmp['x'] = 'RHEL';
tmp['osname'] = public.readFile('/etc/redhat-release').split()[0];
elif os.path.exists('/etc/issue'):
tmp['x'] = 'Debian';
tmp['osname'] = public.readFile('/etc/issue').split()[0];
web.ctx.session.server_os = tmp
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:10,代码来源:common.py
示例13: close_ssh_limit
def close_ssh_limit(self,get):
#清除白名单
allowConf = public.readFile(self.__ALLOW);
allowConf = re.sub("\n\s*sshd:\w{1,3}\.\w{1,3}\.\w{1,3}\.\w{1,3}:allow",'',allowConf);
public.writeFile(self.__ALLOW,allowConf);
#关闭限制
denyConf = public.readFile(self.__DENY);
denyConf = re.sub("sshd:ALL\s*","",denyConf);
public.writeFile(self.__DENY,denyConf);
return public.returnMsg(True,'清除成功!');
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:11,代码来源:safelogin_main.py
示例14: install
def install(self,get):
pluginInfo = self.GetFind(get.name);
if not pluginInfo:
import json
pluginInfo = json.loads(public.readFile(self.__install_path + '/' + get.name + '/info.json'));
if pluginInfo['tip'] == 'lib':
if not os.path.exists(self.__install_path + '/' + pluginInfo['name']): os.system('mkdir -p ' + self.__install_path + '/' + pluginInfo['name']);
if not hasattr(web.ctx.session,'downloadUrl'): web.ctx.session.downloadUrl = 'http://download.bt.cn';
downloadUrl = web.ctx.session.downloadUrl + '/install/lib/plugin/' + pluginInfo['name'] + '/install.sh';
toFile = self.__install_path + '/' + pluginInfo['name'] + '/install.sh';
public.downloadFile(downloadUrl,toFile);
os.system('/bin/bash ' + toFile + ' install');
if self.checksSetup(pluginInfo['name'],pluginInfo['checks'],pluginInfo['versions'])[0]['status'] or os.path.exists(self.__install_path + '/' + get.name):
public.WriteLog('TYPE_SETUP','PLUGIN_INSTALL_LIB',(pluginInfo['title'],));
os.system('rm -f ' + toFile);
return public.returnMsg(True,'PLUGIN_INSTALL_SUCCESS');
return public.returnMsg(False,'PLUGIN_INSTALL_ERR');
else:
import db,time
path = web.ctx.session.setupPath + '/php'
if not os.path.exists(path): os.system("mkdir -p " + path);
issue = public.readFile('/etc/issue')
if web.ctx.session.server_os['x'] != 'RHEL': get.type = '3'
apacheVersion='false';
if public.get_webserver() == 'apache':
apacheVersion = public.readFile(web.ctx.session.setupPath+'/apache/version.pl');
public.writeFile('/var/bt_apacheVersion.pl',apacheVersion)
public.writeFile('/var/bt_setupPath.conf',web.ctx.session.rootPath)
isTask = '/tmp/panelTask.pl'
mtype = 'install';
mmsg = '安装';
if hasattr(get, 'upgrade'):
if get.upgrade:
mtype = 'update';
mmsg = 'upgrade';
execstr = "cd " + web.ctx.session.setupPath + "/panel/install && /bin/bash install_soft.sh " + get.type + " "+mtype+" " + get.name + " "+ get.version;
sql = db.Sql()
if hasattr(get,'id'):
id = get.id;
else:
id = None;
sql.table('tasks').add('id,name,type,status,addtime,execstr',(None, mmsg + '['+get.name+'-'+get.version+']','execshell','0',time.strftime('%Y-%m-%d %H:%M:%S'),execstr))
public.writeFile(isTask,'True')
public.WriteLog('TYPE_SETUP','PLUGIN_ADD',(get.name,get.version));
return public.returnMsg(True,'PLUGIN_INSTALL');
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:48,代码来源:panelPlugin.py
示例15: GetLibInfo
def GetLibInfo(self,name):
import json
tmp = public.readFile('data/libList.conf');
data = json.loads(tmp)
for lib in data:
if name == lib['opt']: return lib;
return False;
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:7,代码来源:ajax.py
示例16: GetConfig
def GetConfig(self,get):
try:
cfile = self.__setupPath + '/config.conf'
if not os.path.exists(cfile): cfile = 'data/beta.pl'
return public.readFile(cfile).strip();
except:
return 'False';
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:7,代码来源:beta_main.py
示例17: checkRule
def checkRule(self):
ruleFile = 'data/rule.json';
if not os.path.exists(ruleFile): return False;
toPath = web.ctx.path.replace('/','');
ruleList = public.readFile(ruleFile).split('|');
if toPath in ruleList: return True;
return False;
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:7,代码来源:common.py
示例18: GetPHPConf
def GetPHPConf(self,get):
gets = [
{'name':'short_open_tag','type':1,'ps':public.getMsg('PHP_CONF_1')},
{'name':'asp_tags','type':1,'ps':public.getMsg('PHP_CONF_2')},
{'name':'max_execution_time','type':2,'ps':public.getMsg('PHP_CONF_4')},
{'name':'max_input_time','type':2,'ps':public.getMsg('PHP_CONF_5')},
{'name':'memory_limit','type':2,'ps':public.getMsg('PHP_CONF_6')},
{'name':'post_max_size','type':2,'ps':public.getMsg('PHP_CONF_7')},
{'name':'file_uploads','type':1,'ps':public.getMsg('PHP_CONF_8')},
{'name':'upload_max_filesize','type':2,'ps':public.getMsg('PHP_CONF_9')},
{'name':'max_file_uploads','type':2,'ps':public.getMsg('PHP_CONF_10')},
{'name':'default_socket_timeout','type':2,'ps':public.getMsg('PHP_CONF_11')},
{'name':'error_reporting','type':3,'ps':public.getMsg('PHP_CONF_12')},
{'name':'display_errors','type':1,'ps':public.getMsg('PHP_CONF_13')},
{'name':'cgi.fix_pathinfo','type':0,'ps':public.getMsg('PHP_CONF_14')},
{'name':'date.timezone','type':3,'ps':public.getMsg('PHP_CONF_15')}
]
phpini = public.readFile('/www/server/php/' + get.version + '/etc/php.ini');
result = []
for g in gets:
rep = g['name'] + '\s*=\s*([0-9A-Za-z_& ~]+)(\s*;?|\r?\n)';
tmp = re.search(rep,phpini)
if not tmp: continue;
g['value'] = tmp.groups()[0];
result.append(g);
return result;
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:28,代码来源:config.py
示例19: setFpmConfig
def setFpmConfig(self,get):
version = get.version
max_children = get.max_children
start_servers = get.start_servers
min_spare_servers = get.min_spare_servers
max_spare_servers = get.max_spare_servers
pm = get.pm
file = web.ctx.session.setupPath+"/php/"+version+"/etc/php-fpm.conf";
conf = public.readFile(file);
rep = "\s*pm.max_children\s*=\s*([0-9]+)\s*";
conf = re.sub(rep, "\npm.max_children = "+max_children, conf);
rep = "\s*pm.start_servers\s*=\s*([0-9]+)\s*";
conf = re.sub(rep, "\npm.start_servers = "+start_servers, conf);
rep = "\s*pm.min_spare_servers\s*=\s*([0-9]+)\s*";
conf = re.sub(rep, "\npm.min_spare_servers = "+min_spare_servers, conf);
rep = "\s*pm.max_spare_servers \s*=\s*([0-9]+)\s*";
conf = re.sub(rep, "\npm.max_spare_servers = "+max_spare_servers+"\n", conf);
rep = "\s*pm\s*=\s*(\w+)\s*";
conf = re.sub(rep, "\npm = "+pm+"\n", conf);
public.writeFile(file,conf)
public.phpReload(version);
public.WriteLog("TYPE_PHP",'PHP_CHILDREN', (version,max_children,start_servers,min_spare_servers,max_spare_servers));
return public.returnMsg(True, 'SET_SUCCESS');
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:30,代码来源:config.py
示例20: getFpmConfig
def getFpmConfig(self,get):
version = get.version;
file = web.ctx.session.setupPath+"/php/"+version+"/etc/php-fpm.conf";
conf = public.readFile(file);
data = {}
rep = "\s*pm.max_children\s*=\s*([0-9]+)\s*";
tmp = re.search(rep, conf).groups();
data['max_children'] = tmp[0];
rep = "\s*pm.start_servers\s*=\s*([0-9]+)\s*";
tmp = re.search(rep, conf).groups();
data['start_servers'] = tmp[0];
rep = "\s*pm.min_spare_servers\s*=\s*([0-9]+)\s*";
tmp = re.search(rep, conf).groups();
data['min_spare_servers'] = tmp[0];
rep = "\s*pm.max_spare_servers \s*=\s*([0-9]+)\s*";
tmp = re.search(rep, conf).groups();
data['max_spare_servers'] = tmp[0];
rep = "\s*pm\s*=\s*(\w+)\s*";
tmp = re.search(rep, conf).groups();
data['pm'] = tmp[0];
return data
开发者ID:soitun,项目名称:BaoTa-Panel,代码行数:26,代码来源:config.py
注:本文中的public.readFile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论