#coding=utf-8 import os,sys,json,re,time,datetime,logging,zipfile,platform from bottle import request,route,template,static_file,abort,redirect from MySQL import writeDb,readDb,readDb2 from Login import checkLogin,checkAccess from FTP import FTPHandle from Functions import AppServer,LoginCls,cmdhandle,writeFTPconf,GetFileMd5,is_chinese,netModule,servchk import Global as gl #支持中文配置读取 sys.setdefaultencoding('utf-8') cmds=cmdhandle() netmod=netModule() @route('/systeminfo') @route('/') @checkAccess def systeminfo(): """系统信息项""" s = request.environ.get('beaker.session') info=dict() info['hostname'] = platform.node() info['kernel'] = platform.platform() info['systime'] = cmds.getdictrst('date +"%Y%m%d %H:%M:%S"').get('result') cmdRun='cat /proc/uptime|awk -F. \'{run_days=$1/86400;run_hour=($1%86400)/3600;run_minute=($1%3600)/60;run_second=$1%60;printf("%d天%d时%d分%d秒",run_days,run_hour,run_minute,run_second)}\'' info['runtime'] = cmds.getdictrst(cmdRun).get('result') info['pyversion'] = platform.python_version() info['memsize'] = cmds.getdictrst('cat /proc/meminfo |grep \'MemTotal\' |awk -F: \'{printf ("%.0fM",$2/1024)}\'|sed \'s/^[ \t]*//g\'').get('result')
#!/usr/bin/env python #coding=utf-8 import os,sys,json,re,logging,time,datetime,hashlib from bottle import request,route,error,run,default_app from bottle import template,static_file,redirect,abort import bottle from MySQL import writeDb,readDb from Login import checkLogin,checkAccess from Functions import cmdhandle,netModule,writeNIconf,writeUTMconf,writeDNSconf,writeROUTEconf cmds = cmdhandle() netmod = netModule() @route('/networkconf') @checkAccess def networkconf(): s = request.environ.get('beaker.session') #清理所有网卡信息,重新获取最新的系统网卡信息 sql = "delete from sysattr where servattr='netiface'" writeDb(sql,) netmod.InitNIinfo() netmod.getifaceData('getni') return template('networkconf',session=s,msg={}) @route('/api/getifaceinfo',method=['GET', 'POST']) @checkAccess def getifaceinfo(): sql = " SELECT id,ifacename,ifacetype,ipaddr,netmask,gateway,rxdata,txdata,status FROM netiface " iface_list = readDb(sql,)