5 Star 3 Fork 1

科学大数据开源社区/文件传输系统-transfer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
client.cpp 2.28 KB
一键复制 编辑 原始数据 按行查看 历史
root 提交于 2017-07-20 15:11 +08:00 . to test performance
#include "client.h"
void transread(const char *host,const char *filepath,const char *targetdir,const char *uid,const char *gid,const char *position,const char *size)
{
Py_Initialize();
if(!Py_IsInitialized())
{
printf("can't initialize\n");
}
PyObject * pModule = NULL;
PyObject * pFunc = NULL;
PyObject * result = NULL;
PyRun_SimpleString("import sys");
PyRun_SimpleString("import os");
PyRun_SimpleString("import string");
PyRun_SimpleString("sys.path.append('./')");
PyObject *pArgs = PyTuple_New(7);
PyTuple_SetItem(pArgs,0,Py_BuildValue("s",host));
PyTuple_SetItem(pArgs,1,Py_BuildValue("s",filepath));
PyTuple_SetItem(pArgs,2,Py_BuildValue("s",targetdir));
PyTuple_SetItem(pArgs,3,Py_BuildValue("s",uid));
PyTuple_SetItem(pArgs,4,Py_BuildValue("s",gid));
PyTuple_SetItem(pArgs,5,Py_BuildValue("s",position));
PyTuple_SetItem(pArgs,6,Py_BuildValue("s",size));
printf("size is %s\n",size);
pModule = PyImport_ImportModule("client");
if(pModule == NULL)
{
printf("can't load module\n");
}
pFunc = PyObject_GetAttrString(pModule,"readentrance");
if(pFunc == NULL)
{
printf("can't load function\n");
}
result = PyEval_CallObject(pFunc,pArgs);
cout<<result<<endl;
Py_DECREF(pArgs);
if(result == NULL)
cout<<"null"<<endl;
Py_DECREF(result);
Py_Finalize();
//return 0;
}
void transupload(const char *host,const char *filepath,const char *targetdir)
{
Py_Initialize();
if(!Py_IsInitialized())
{
printf("can't initialize\n");
}
PyObject * pModule = NULL;
PyObject * pFunc = NULL;
PyObject * result = NULL;
PyRun_SimpleString("import sys");
PyRun_SimpleString("import os");
PyRun_SimpleString("import string");
PyRun_SimpleString("sys.path.append('./')");
PyObject *pArgs = PyTuple_New(3);
PyTuple_SetItem(pArgs,0,Py_BuildValue("s",host));
PyTuple_SetItem(pArgs,1,Py_BuildValue("s",filepath));
PyTuple_SetItem(pArgs,2,Py_BuildValue("s",targetdir));
pModule = PyImport_ImportModule("client");
// printf("host %s",host);
if(pModule == NULL)
{
printf("can't load module\n");
}
pFunc = PyObject_GetAttrString(pModule,"uploadentrance");
if(pFunc == NULL)
{
printf("can't load function\n");
}
result = PyEval_CallObject(pFunc,pArgs);
Py_DECREF(pArgs);
if(result == NULL)
cout<<"null"<<endl;
Py_DECREF(result);
Py_Finalize();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/opensci/transfer.git
git@gitee.com:opensci/transfer.git
opensci
transfer
文件传输系统-transfer
master

搜索帮助