【问题标题】:GWT and python on the server side服务器端的 GWT 和 python
【发布时间】:2014-09-25 14:57:22
【问题描述】:

我是 GWT 的新手,我有一个在 GWT 上开发的应用程序。我需要在服务器端集成一个用 python 开发的程序。使用 python 开发的应用程序必须获取一个 MalLab 文件,然后生成一些格式为 .PNG 的文件。目前我对 python 程序进行了更改,因为它必须将文件放在特定的 URL 上。您的想法是如何在服务器端将 GWT 应用程序与 python 集成?

python中的程序是:

#!/usr/bin/python
# -*- coding: utf-8 -*-
import scipy.io
import pylab as pl
import numpy as np
from scipy import misc
from glob import glob

# import file into a dictionary
fMatLab = scipy.io.loadmat('St3D', mat_dtype = True, squeeze_me = True, struct_as_record=False)

# read in the structure
data = fMatLab['St3D']

for i in range(data.shape[2]):
    misc.imsave('transect_%s.png' % i, data[:,:,i] )
    img = scipy.misc.toimage(data[:,:,i], mode='I')

【问题讨论】:

  • 这里的 GWT 没有什么特别之处。只需使用 this 之类的东西。
  • gwt 服务器端没有什么特别之处,您所需要的只是将您的 python 脚本与 java 集成,我为此使用了 jython,您可以在 pythhon 中创建其他服务器,然后调用它直接从 gwt 前端
  • 如何做到的:you could create rest server in pythhon, and call it directlu from gwt frond end 请您进一步发展这个想法

标签: java python gwt service daemon


【解决方案1】:

你需要在 RemoteServlet 上做的就是写几行 java 代码来执行你的脚本

String[] cmd = {
    "/bin/bash",
    "-c",
    "python script.py \"" + path_to_matlab_file + "\""
};
Runtime.getRuntime().exec(cmd);

【讨论】:

  • 我把“script.py 程序”放在哪里了?运行服务时出现 java.security.AccessControlException: access denied ("java.io.FilePermission" ">" "execute")
猜你喜欢
  • 1970-01-01
  • 2011-03-31
  • 1970-01-01
  • 1970-01-01
  • 2012-06-10
  • 2011-10-16
  • 1970-01-01
  • 1970-01-01
  • 2017-03-24
相关资源
最近更新 更多