apache - Error wsgi in server installed in MAC Yosemite -


i have problems wsgi module , not understand why. installed apache, remove mamp because gave me many problems. have configured port , page loads fine. install mysql load script , well. install python-mysql connector , make connection , connects. when access site , want register strip mistake, nose if reaches database or not. me understand happens.

attached codes.

httpd.conf

serverroot "/usr/local/apache2"  listen 8080  loadmodule authn_file_module modules/mod_authn_file.so loadmodule authn_core_module modules/mod_authn_core.so loadmodule authz_host_module modules/mod_authz_host.so loadmodule authz_groupfile_module modules/mod_authz_groupfile.so loadmodule authz_user_module modules/mod_authz_user.so loadmodule authz_core_module modules/mod_authz_core.so loadmodule access_compat_module modules/mod_access_compat.so loadmodule auth_basic_module modules/mod_auth_basic.so loadmodule socache_shmcb_module modules/mod_socache_shmcb.so loadmodule reqtimeout_module modules/mod_reqtimeout.so loadmodule filter_module modules/mod_filter.so loadmodule mime_module modules/mod_mime.so loadmodule log_config_module modules/mod_log_config.so loadmodule env_module modules/mod_env.so loadmodule headers_module modules/mod_headers.so #loadmodule unique_id_module modules/mod_unique_id.so loadmodule setenvif_module modules/mod_setenvif.so loadmodule version_module modules/mod_version.so loadmodule ssl_module modules/mod_ssl.so loadmodule unixd_module modules/mod_unixd.so #loadmodule dav_module modules/mod_dav.so loadmodule status_module modules/mod_status.so loadmodule autoindex_module modules/mod_autoindex.so loadmodule alias_module modules/mod_alias.so loadmodule wsgi_module modules/mod_wsgi.so  <ifmodule unixd_module>  user daemon group daemon  </ifmodule> serveradmin usuario@usuario.com servername localhost:8080 <directory />     allowoverride none     require denied </directory> documentroot "/users/usuario/sites/usuariocloud/client" <directory "/users/usuario/sites/usuariocloud/client">     options indexes followsymlinks     allowoverride none     require granted </directory>  <ifmodule dir_module>     directoryindex index.html </ifmodule>  <files ".ht*">     require denied </files>  errorlog "logs/error_log" loglevel warn  <ifmodule log_config_module>     logformat "%h %l %u %t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\"" combined     logformat "%h %l %u %t \"%r\" %>s %b" common      <ifmodule logio_module>       logformat "%h %l %u %t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\" %i %o" combinedio     </ifmodule>      customlog "logs/access_log" common </ifmodule>  <ifmodule alias_module>     scriptalias /cgi-bin/ "/users/usuario/sites/usuariocloud/server/" </ifmodule>  <ifmodule cgid_module> </ifmodule>  alias /cgi-bin /users/usuario/sites/usuariocloud/server/ <location /cgi-bin>    sethandler wsgi-script    options +execcgi </location>  #wsgiscriptalias /cgi-bin /users/usuario/sites/usuariocloud/server/  <directory "/users/usuario/sites/usuariocloud/server/">     allowoverride none     options none     require granted </directory>  <ifmodule mime_module>     typesconfig conf/mime.types      addtype application/x-compress .z     addtype application/x-gzip .gz .tgz  </ifmodule>  <ifmodule proxy_html_module> include conf/extra/proxy-html.conf </ifmodule>  include conf/extra/httpd-ssl.conf <ifmodule ssl_module> sslrandomseed startup builtin sslrandomseed connect builtin </ifmodule> 

controller.wsgi

    # library imports import json, cgi, sys, os  path =  os.path.dirname(__file__)  if path not in sys.path:     sys.path.append(path)  # own libraries petition_solver.solver import solver  def application(env, resp):     response = {    "response": "fail",                      "error" : """expecting ?json=                                 {                                     "function":"functionname",                                     "entity":"entityname",                                     "params":                                     {                                         "param1":"value1",                                          "param2":"value2",                                          "paramn":"value n"                                     }                                 }""".replace('\r', ' ').replace('\n', ' ').replace('\t', '')                    }      # read params      form = cgi.fieldstorage(fp=env['wsgi.input'], environ=env)      if form:          useragent = env["http_user_agent"] if "http_user_agent" in env else ""         param_json = form['json'].value          petition = json.loads(param_json)          if('file' in form , "params" in petition):             param_file = form['file']              if(isinstance(param_file, list)):                 petition['params']['files'] = []                 f in param_file:                     filename = unicode(f.filename, 'utf-8')                     petition['params']['files'].append({"originalname" : filename, "file" : f.file.read()})             else:                 petition['params']['file'] = param_file.file.read()                 filename = unicode(param_file.filename, 'utf-8')                 petition['params']['originalname'] = filename          solver = solver()         response = solver.solvepetition(petition, useragent=useragent)      if (response , "download" in response , response["download"]):          detail = response["file"]["storage"]          mime = detail["mime"].decode('utf-8')         name = detail["originalname"].encode("ascii", 'replace')         data = detail["file"]          resp('200 ok',[('content-type', '{0}'.format(mime)),('content-disposition', 'attachment; filename*=utf-8''{0}; filename={0}'.format(name))])         yield data     else:         resp('200 ok',[('content-type', 'text/html;charset=utf-8')])         yield json.dumps(response) 

solver.py

#solver module  #class solver  log import log error import notvalidpetitionerror  class solver:      userid = -1     def solvepetition(self, petition, petitionid=0, useragent=none):          lg = log.instance()          if("function" not in petition or "entity" not in petition):             response = {"response":"fail",  "error" : "{0}".format(notvalidpetitionerror())}             lg.logerror("not valid petition found", lg.solver_level)             return response          innerpetition = self._getcopy(petition)          function = innerpetition["function"]         entityname = innerpetition["entity"]         params = innerpetition["params"] if "params" in innerpetition else {}         key = innerpetition["key"] if "key" in innerpetition else ""         #petitionid = petitionid if petitionid else self._getpetitionid()          #lg.logdebug("received petition {0} ".format(self._getjsonrepr(petition)), lg.solver_level, petitionid)          entity = none         entitytype = none          if(entityname == "user"):             entities.user import user             entitytype = user             params["useragent"] = useragent         elif(entityname == "group"):             entities.group import group             entitytype = group         elif(entityname == "tag"):             entities.tag import tag             entitytype = tag                 elif(entityname == "attribute"):             entities.attribute import attribute             entitytype = attribute         elif(entityname == "template"):             entities.template import template             entitytype = template         elif(entityname == "directory"):             entities.directory import directory             entitytype = directory         elif(entityname == "staticcatalog"):             entities.staticcatalog import staticcatalog             entitytype = staticcatalog         elif(entityname == "dynamiccatalog"):             entities.dynamiccatalog import dynamiccatalog             entitytype = dynamiccatalog         elif(entityname == "document"):             entities.document import document             entitytype = document         elif(entityname == "file"):             entities.file import file             entitytype = file         elif(entityname == "inbox"):             entities.inbox import inbox             entitytype = inbox         elif(entityname == "storagefile"):             entities.storagefile import storagefile             entitytype = storagefile         elif(entityname == "structure"):             entities.structure import structure             entitytype = structure         elif(entityname == "dictionarycatalog"):             entities.dictionarycatalog import dictionarycatalog             entitytype = dictionarycatalog         elif(entityname == "patterntemplate"):             entities.patterntemplate import patterntemplate             entitytype = patterntemplate          if petitionid:             petitionid = petitionid             valuereturned = self._operationsmanager(params, petitionid, key, entitytype, entityname, function, false, petition)          else:             petitionid = self._getpetitionid()             valuereturned = self._operationsmanager(params, petitionid, key, entitytype, entityname, function, true, petition)          lg.logdebug("received petition {0} ".format(self._getjsonrepr(petition)), lg.solver_level, petitionid)          try:             entity = entitytype(params, key, petitionid)             response = entity.process(function)             pet_id = self._getpetition(entity, petitionid)             queryupdate = self._getdbtemplate("update_operation_status").format(pet_id)             newid = entity._resolveupdate(queryupdate, audit=false)             if newid > 0:                 lg.logdebug("update_petition_id: {0} ".format(pet_id), lg.solver_level, petitionid)         except exception e:             response = self._manageerror(e, petition, petitionid)         finally:             del (entity)             del (innerpetition)          lg.logdebug("response petition {0}".format(self._getjsonrepr(response)), lg.solver_level, petitionid)          response["petition"] = self._getjsonwofile(petition)         return response      def _getjsonrepr(self, json):          j = self._getjsonwofile(json["file"]) if "file" in json else self._getjsonwofile(json)          return "{0}".format(j)      def _getjsonwofile(self, json):          needscopy = json , "file" in json or (                         "params" in json , json["params"] , (                             "file" in json["params"] or "files" in json["params"]                         )                     ) or "storage" in json          if needscopy:              copy = self._getcopy(json)              if ("file" in copy):                 copy["file"] = "file data omitted" if copy["file"] else "empty file"              if ("storage" in copy):                 if ("file" in copy["storage"]):                     copy["storage"]["file"] = "file data omitted" if copy["storage"]["file"] else "empty file"              if("params" in copy):                     if("files" in copy["params"]):                     f in copy['params']["files"]:                         f["file"] = "file data omitted" if f["file"] else "empty file"                  if("file" in copy["params"]):                     copy["params"]["file"] = "file data omitted" if copy["params"]["file"] else "empty file"               return copy          else:             return json      def _getcopy(self, json):          import copy          copy = copy.deepcopy(json)          return copy      def _manageerror(self, err, petition, petitionid):          error import usuarioerror          innererror = err if isinstance(err, usuarioerror) else usuarioerror()          lg = log.instance()         lgmethod = lg.logwarning if innererror.code < 400 else lg.logerror         lgmethod("{0} found while resolving petition {1}".format( str(innererror) , petitionid), lg.solver_level, petitionid)          response = {             "response":"fail",             "error" : {                 "code" : "{0}".format(innererror.code),                 "message" : str(innererror)             }         }          return response      def _getpetitionid(self):          import uuid          uuidobj = uuid.uuid4()          return uuidobj.hex      def _getdbtemplate(self, templatename):         dbtemplateprovider = none         if not dbtemplateprovider:             db_template_provider import dbtemplateprovider             dbtemplateprovider = dbtemplateprovider.instance()          return dbtemplateprovider.getdbtemplate(templatename)      def _findfunction(self, functionname, entitytype):         queryfunction = self._getdbtemplate("find_function_id").format(functionname)         rows = entitytype._resolvequery(queryfunction, function=functionname, audit=false)         if rows:             functionid = rows[0]             fcid = functionid[0]             return fcid         return 0      def _findentity(self, entityname, entitytype):         queryentity = self._getdbtemplate("find_entity_id").format(entityname)         rows = entitytype._resolvequery(queryentity, audit=false)         if rows:             entityid = rows[0]             entid = entityid[0]             return entid         return 0      def _addoperation(self, function, entityname, entity, newid, typeoper, petitionid):         lg = log.instance()         functionid = self._findfunction(function, entity)         entityid = self._findentity(entityname, entity)         queryoperation = ""         if typeoper:             queryoperation = self._getdbtemplate("create_operations").format(newid, functionid, entityid, 0, 2)         else:             queryoperation = self._getdbtemplate("create_operations").format(newid, functionid, entityid, 0, 1)         entity._resolveupdate(queryoperation, false)         lg.logdebug("operation added: {0}".format(newid), lg.solver_level, petitionid)      def _getpetition(self, entitytype, petitionid):         querypetition = self._getdbtemplate("find_petition_id").format(petitionid)         required = []         rows = entitytype._resolvequery(querypetition, audit=false)         if rows:             petid = rows[0]             petid_ = petid[0]             return petid_         return 0      def _operationsmanager(self, params, petitionid, key, entitytype, entityname, function, typeoper, petition):         entity = none         newid = 0         lg = log.instance()         try:             entity = entitytype(params, key, petitionid)              if typeoper:                 jsonstr = self._getjsonrepr(petition).replace("\'", "\\\'")                 username = self._findusername(entity, key)                 if self.userid != -1:                     queryregistry = self._getdbtemplate("create_registry_petitions").format(petitionid, jsonstr, "final", 0, self.userid, username, 5)                     lg.logdebug("registry query: {0}".format(jsonstr), lg.solver_level, petitionid)                     newid = entity._resolveupdate(queryregistry, audit=false)                      if newid > 0:                         lg.logdebug("petition added: {0}".format(jsonstr), lg.solver_level, petitionid)                         self._addoperation(function, entityname, entity, newid, true, petitionid)                     else:                         return false                     return true                 else:                     return false             else:                 newid = self._getpetition(entity, petitionid)                 self._addoperation(function, entityname, entity, newid, false, petitionid)          except exception e:             lg.logerror(self._manageerror(e, petition, petitionid), lg.solver_level, petitionid)             return false      def _findusername(self, entity, key):         usertemplate = self._getdbtemplate("query_user_by_key").format(key)         rowsid = entity._resolvequery(usertemplate)         if rowsid:             self.userid = rowsid[0][0]             nametemplate = self._getdbtemplate("query_username").format(self.userid)             rowsusr = entity._resolvequery(nametemplate)             if rowsusr:                 username = rowsusr[0][0]                 return username         return none 

and error isenter image description here

and logs nexts

[thu jun 18 12:04:37.413641 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] mod_wsgi (pid=2048): exception occurred processing wsgi script '/users/usuario/sites/usuariocloud/server/controller.wsgi'., referer: http://localhost:8080/\ [thu jun 18 12:04:37.413692 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] traceback (most recent call last):, referer: http://localhost:8080/\ [thu jun 18 12:04:37.413719 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302]   file "/users/usuario/sites/usuariocloud/server/controller.wsgi", line 53, in application, referer: http://localhost:8080/\ [thu jun 18 12:04:37.413759 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302]     response = solver.solvepetition(petition, useragent=useragent), referer: http://localhost:8080/\ [thu jun 18 12:04:37.413775 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302]   file "/users/usuario/sites/usuariocloud/server/petition_solver/solver.py", line 13, in solvepetition, referer: http://localhost:8080/\ [thu jun 18 12:04:37.413795 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302]     lg = log.instance(), referer: http://localhost:8080/\ [thu jun 18 12:04:37.413805 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302]   file "/users/usuario/sites/usuariocloud/server/petition_solver/singleton.py", line 34, in instance, referer: http://localhost:8080/\ [thu jun 18 12:04:37.413823 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302]     self._instance = self._decorated(), referer: http://localhost:8080/\ [thu jun 18 12:04:37.413833 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302]   file "/users/usuario/sites/usuariocloud/server/petition_solver/log.py", line 24, in __init__, referer: http://localhost:8080/\ [thu jun 18 12:04:37.413849 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302]     os.makedirs(directory), referer: http://localhost:8080/\ [thu jun 18 12:04:37.413859 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302]   file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/os.py", line 157, in makedirs, referer: http://localhost:8080/\ [thu jun 18 12:04:37.413878 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302]     mkdir(name, mode), referer: http://localhost:8080/\ [thu jun 18 12:04:37.413897 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] oserror: [errno 13] permission denied: '//logs', referer: http://localhost:8080/\ [thu jun 18 12:54:13.192665 2015] [mpm_worker:notice] [pid 2046:tid 140735125234432] ah00295: caught sigterm, shutting down\ 

your code trying write log file using relative path. cannot current working directory of process '/' , not code is. see:

use absolute path explicitly, or calculate relative code location using os.path.dirname(__file__) base.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -