从web.py运行时,完美运行的python脚本会产生错误 [英] Perfectly running python script gives error when run from web.py

查看:367
本文介绍了从web.py运行时,完美运行的python脚本会产生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下python脚本,如果单独运行,则可以完美运行:

I have the following python script which runs perfectly if run separately:

import arcpy 

val = arcpy.GetCellValue_management("D:\dem-merged\lidar_wsg84", "-95.090174910630012 29.973962146120652", "")
print str(val)

我想将此作为Web服务公开,所以我安装了web.py并为code.py编写了以下代码.但是会产生错误(调用时可以编译.)

I want to expose this as a web service and so I installed web.py and wrote the following code for code.py. but it gives errors(when invoked. compiles fine).

import web
import arcpy        
urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:        
    def GET(self, name):

        val = arcpy.GetCellValue_management("D:\dem-merged\lidar_wsg84", "-95.090174910630012 29.973962146120652", "")
        return  str(val)

if __name__ == "__main__":
    app.run()

当我使用 http://localhost:8080 调用此函数时,出现以下错误:

When i invoke this using http://localhost:8080, i get the following error:

<class 'arcgisscripting.ExecuteError'> at /
ERROR 000582: Error occurred during execution.

Python  C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\management.py in GetCellValue, line 8460
Web GET http://localhost:8080/
Traceback (innermost first)

C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\management.py in GetCellValue
          be returned."""
    try:

        retval = convertArcObjectToPythonObject(gp.GetCellValue_management(*gp_fixargs((in_raster, location_point, band_index), True)))
        return retval
    except Exception, e:
        raise e ...
@gptooldoc('GetRasterProperties_management', None)
def GetRasterProperties(in_raster=None, property_type=None):
    """GetRasterProperties_management(in_raster, {property_type})
        Returns the properties of a raster dataset.

我尝试了多种调试方式,如果我只是返回"hello",则代码.py可以很好地运行.我正在使用的库是ArcGIS Geoprocessing工具箱库.

I have tried Debugging it in many ways, the code .py runs fine if i just return a "hello". The library i am using is a ArcGIS Geoprocessing toolbox library.

关于什么可能有问题的任何想法?

Any ideas as to what might be wrong?

推荐答案

这似乎是第三方模块中的错误.尝试找出该错误代码(000582)对应用程序实际意味着什么.

That looks like an error from the third party module. Try finding out what that error code (000582) actually means to the application.

这篇关于从web.py运行时,完美运行的python脚本会产生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆