本文整理汇总了Python中mod_python.apache.log_error函数的典型用法代码示例。如果您正苦于以下问题:Python log_error函数的具体用法?Python log_error怎么用?Python log_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_more_stuff
def do_more_stuff(req, links_str):
links_with_depth = links_str.split("|||");
links = []
for each in links_with_depth:
if each != "":
each_link_and_depth = each.split("||")
apache.log_error(str(each_link_and_depth))
links.append(each_link_and_depth);
apache.log_error(links_str);
#apache.log_error(str(len(links_str)));
#apache.log_error(str(links))
result = dist_crawl.start_processing([], links, 0);
map_res = result[0]
result.pop(0);
map_to_arr = []
for each in map_res:
map_to_arr.append([each] + map_res[each])
result.insert(0, map_to_arr);
more_results = result[0]
ret_html = ""
for res in more_results:
ret_html = ret_html + "<tr>"
for col in res:
ret_html = ret_html + "<td>" + str(col) + "</td>"
ret_html = ret_html + "</tr>"
return ret_html
示例2: index
def index (req, repo=None, version="0.0.0", OS="None"):
if not repo:
repolist = ""
desc = "Download " + " ".join ([repo["name"] for repo in lib.get_config ("Repositories","Downloads")])
for repo in lib.get_config ("Repositories","Downloads"):
try:
repolist += _snippet_for_repo (None, repo)
except Exception as e:
apache.log_error (str(e))
return lib.respond (req, "<div class='news'>"+repolist+"<br/><br/></div>", "Downloads", "Downloads", desc, module_info ())
else:
repository = None
for entry in lib.get_config ("Repositories","Downloads"):
if entry["repo"] == repo:
repository = entry
break
else:
return lib.e404 (req, "Could not find a matching repository.", module_info())
try:
ver = _latest_ver (repo=repository)
except Exception as e:
apache.log_error (traceback.format_exc())
return lib.e404 (req, "Repository corrupt or wrong configuration, please contact the administrator.", module_info())
if version == ver:
return lib.respond (req, "You're already running the lastest version of %s." % repository["name"], "Downloads", "Downloads", "Updater", module_info())
else:
return lib.respond (req, _snippet_for_repo (repo=repository),"Downloads", "Downloads", "Download %s" % repository["name"], module_info())
示例3: handler
def handler(req):
"""HTTP request handler"""
_options = req.get_options()
_home = _options.get("TrackerHome")
_lang = _options.get("TrackerLanguage")
_timing = _options.get("TrackerTiming", "no")
if _timing.lower() in ("no", "false"):
_timing = ""
_debug = _options.get("TrackerDebug", "no")
_debug = _debug.lower() not in ("no", "false")
if not (_home and os.path.isdir(_home)):
apache.log_error(
"PythonOption TrackerHome missing or invalid for %(uri)s"
% {'uri': req.uri})
return apache.HTTP_INTERNAL_SERVER_ERROR
_tracker = roundup.instance.open(_home, not _debug)
# create environment
# Note: cookies are read from HTTP variables, so we need all HTTP vars
req.add_common_vars()
_env = dict(req.subprocess_env)
# XXX classname must be the first item in PATH_INFO. roundup.cgi does:
# path = string.split(os.environ.get('PATH_INFO', '/'), '/')
# os.environ['PATH_INFO'] = string.join(path[2:], '/')
# we just remove the first character ('/')
_env["PATH_INFO"] = req.path_info[1:]
if _timing:
_env["CGI_SHOW_TIMING"] = _timing
_form = cgi.FieldStorage(req, environ=_env)
_client = _tracker.Client(_tracker, Request(req), _env, _form,
translator=TranslationService.get_translation(_lang,
tracker_home=_home))
_client.main()
return apache.OK
示例4: handler
def handler(req):
"""
Right now, index serves everything.
Hitting this URL means we've already cleared authn/authz
but we still need to use the token for all remote requests.
"""
my_user = __get_user(req)
my_uri = req.uri
sess = __get_session(req)
if not sess.has_key('cobbler_token'):
# using Kerberos instead of Python Auth handler?
# We need to get our own token for use with authn_passthru
# which should also be configured in /etc/cobbler/modules.conf
# if another auth mode is configured in modules.conf this will
# most certaintly fail.
try:
if not os.path.exists("/var/lib/cobbler/web.ss"):
apache.log_error("cannot load /var/lib/cobbler/web.ss")
return apache.HTTP_UNAUTHORIZED
fd = open("/var/lib/cobbler/web.ss")
data = fd.read()
my_pw = data
fd.close()
token = xmlrpc_server.login(my_user,my_pw)
except Exception, e:
apache.log_error(str(e))
return apache.HTTP_UNAUTHORIZED
sess['cobbler_token'] = token
示例5: _create_dispatcher
def _create_dispatcher():
_LOGGER.info('Initializing Dispatcher')
options = apache.main_server.get_options()
handler_root = options.get(_PYOPT_HANDLER_ROOT, None)
if not handler_root:
raise Exception('PythonOption %s is not defined' % _PYOPT_HANDLER_ROOT,
apache.APLOG_ERR)
handler_scan = options.get(_PYOPT_HANDLER_SCAN, handler_root)
allow_handlers_outside_root = _parse_option(
_PYOPT_ALLOW_HANDLERS_OUTSIDE_ROOT,
options.get(_PYOPT_ALLOW_HANDLERS_OUTSIDE_ROOT),
_PYOPT_ALLOW_HANDLERS_OUTSIDE_ROOT_DEFINITION)
dispatcher = dispatch.Dispatcher(
handler_root, handler_scan, allow_handlers_outside_root)
for warning in dispatcher.source_warnings():
apache.log_error(
'mod_pywebsocket: Warning in source loading: %s' % warning,
apache.APLOG_WARNING)
return dispatcher
示例6: handler
def handler(req):
reload(sys) #set default encoding from ascii to utf-8
sys.setdefaultencoding('utf-8')
apache.log_error(req.args)
params = {}
for pair in req.args.split('&'):
key, value = pair.split('=')
params[key] = value
ssid = params['ssid']
password = params['passwd']
req.content_type = "text/plain; charset=utf-8"
req.write('开始连接wifi咯!')
scripts_path = get_scripts_path()
if scripts_path == '':
apache.log_error('scripts_path resolv failed!')
catkin_ws = scripts_path.split('src')[0]
sys.path.append(catkin_ws+'devel/lib/python2.7/dist-packages')
sys.path.append('/opt/ros/hydro/lib/python2.7/dist-packages')
os.environ['ROS_MASTER_URI'] = 'http://localhost:11311'
import rospy
from qbo_config_manager.srv import *
rospy.wait_for_service('/config_connect_user_wifi')
proc = rospy.ServiceProxy('/config_connect_user_wifi', ConnectWifi)
result = proc(ssid, 'p'+password) #ROS 把'123456'理解成数字,而不是字符串,所以要在前面加字母占位符
return apache.OK
示例7: handler
def handler(req):
reload(sys) #set default encoding from ascii to utf-8
sys.setdefaultencoding('utf-8')
apache.log_error(req.args)
params = {}
for pair in req.args.split('&'):
key, value = pair.split('=')
params[key] = value
if params['service'] == 'get_sen':
req.content_type = "text/plain; charset=utf-8"
uid = params['uid']
sen = getSen(uid)
req.write(sen)
return apache.OK
elif params['service'] == 'put_sen':
wav = req.read()
uid = params['uid']
sid = params['sid']
result = putSen(uid, sid, wav)
req.content_type = "text/plain; charset=utf-8"
req.write(result)
return apache.OK
elif params['service'] == 'login':
user_name = unquote(params['user_name']).decode('utf-8')
result = login(user_name)
req.content_type = "text/plain; charset=utf-8"
req.write(result)
return apache.OK
示例8: handler
def handler(req):
#req.content_type = 'text/plain'
#req.write("Hello World!")
if req.method == 'POST':
kwargs = parse_qs(req.read())
elif req.method == 'GET':
kwargs = parse_qs(req.args)
#oldid = os.getuid()
#os.setuid(501)
try:
method=str(kwargs['mode'][0])
methodKWargs=kwargs.remove('mode')
methodKWargs['req']=req
myFilemanager.__dict__['method'](**methodKWargs)
return apache.OK
except KeyError:
return apache.HTTP_BAD_REQUEST
except Exception, (errno, strerror):
apache.log_error(strerror, apache.APLOG_CRIT)
return apache.HTTP_INTERNAL_SERVER_ERROR
示例9: getClasses
def getClasses(req,buld=None,room=None):
req.content_type="application/json"
req.send_http_header()
if buld is None or room is None:
return "classypengins = null;"
buld = re.sub("^[0 ]+","",buld)
room = re.sub("^[0 ]+","",room)
conn = sqlite3.connect(path+'/rota.db')
c = conn.cursor()
c.execute('''SELECT session, start, stop FROM class WHERE building=? AND room=? AND start > ? AND start < ?''',(
buld,
room,
datetime.date.today() + offset,
datetime.date.today() + offset + datetime.timedelta(days=1)
))
res = c.fetchall()
sessions = []
for r in res:
apache.log_error(repr(r),apache.APLOG_DEBUG)
c.execute('''SELECT offering FROM classCourse WHERE session=?''', (r[0],))
offer = c.fetchall()
c.execute('''SELECT course FROM courses WHERE offering=?''',
(offer[0][0],))
classname = c.fetchall()
sessiondict={}
sessiondict['class']=classname[0][0]
sessiondict['start']=r[1]
sessiondict['finish']=r[2]
sessions.append(sessiondict)
return simplejson.dumps(sessions)
示例10: headerparserhandler
def headerparserhandler(req):
options = req.get_options()
realm = None
if options.has_key('Realm'):
realm = options['Realm']
else:
apache.log_error('no realm specified')
return apache.DECLINED
# if the token is in the URL, extract it and send it to the login page
token = None
if req.args != None:
try:
dict = util.FieldStorage(req)
if dict.has_key('token'):
token = dict['token']
except:
pass
sess = Session.Session(req, lock=0)
sess.lock()
sess.set_timeout(SESSION_TIMEOUT)
username = session_user(sess, realm)
if None == username and realm == 'Reports':
username = session_user(sess, 'Administrator')
if None == username and realm == 'SetupWizard':
username = session_user(sess, 'Administrator')
if None == username and realm == 'SetupWizard' and not wizard_password_required():
username = 'setupwizard'
save_session_user(sess, realm, username)
if None == username and is_local_process_uid_authorized(req):
username = 'localadmin'
log_login(req, username, True, True, None)
save_session_user(sess, realm, username)
#if sess.has_key('apache_realms'):
# apache.log_error('DEBUG apache_realms: %s' % sess['apache_realms'])
# if sess['apache_realms'].has_key(realm):
# apache.log_error('DEBUG apache_realms[%s]: %s' % (realm, sess['apache_realms'][realm]))
#else:
# apache.log_error('DEBUG apache_realms: %s' % None)
sess.save()
sess.unlock()
if username != None:
pw = base64.encodestring('%s' % username).strip()
req.headers_in['Authorization'] = "BASIC % s" % pw
req.notes['authorized'] = 'true'
return apache.OK
apache.log_error('Auth failure [Username not specified]. Redirecting to auth page. (realm: %s)' % realm)
login_redirect(req, realm, token)
示例11: phase_status_8
def phase_status_8(req):
apache.log_error("phase_status_8")
apache.log_error("phases = %s" % req.phases)
if req.phases != [1, 2, 5, 6, 7]:
req.write("test failed")
else:
req.write("test ok")
return apache.OK
示例12: log
def log(self, msg):
if self.logger.error_log is self.__error_log:
try:
self.__apache_request.log_error(msg)
except AttributeError:
apache.log_error(msg)
else:
Publisher.log(self, msg)
示例13: _log
def _log(msg, level):
newlevel = apache.APLOG_ERR
if logging.DEBUG >= level:
newlevel = apache.APLOG_DEBUG
elif logging.INFO >= level:
newlevel = apache.APLOG_INFO
elif logging.WARNING >= level:
newlevel = apache.APLOG_WARNING
apache.log_error(msg, newlevel, req.server)
示例14: send_login_event
def send_login_event(client_addr, login, local, succeeded, reason):
# localadmin is used for local machine API calls
# these are not logged
if login == "localadmin":
return
try:
uvmContext = uvm.Uvm().getUvmContext()
uvmContext.adminManager().logAdminLoginEvent( str(login), local, str(client_addr), succeeded, reason )
except Exception, e:
apache.log_error('error: %s' % repr(e))
示例15: _create_dispatcher
def _create_dispatcher():
_HANDLER_ROOT = apache.main_server.get_options().get(
_PYOPT_HANDLER_ROOT, None)
if not _HANDLER_ROOT:
raise Exception('PythonOption %s is not defined' % _PYOPT_HANDLER_ROOT,
apache.APLOG_ERR)
dispatcher = dispatch.Dispatcher(_HANDLER_ROOT)
for warning in dispatcher.source_warnings():
apache.log_error('mod_pywebsocket: %s' % warning, apache.APLOG_WARNING)
return dispatcher