Tag: python

如何发送从graphql的令牌请求到python api?

我需要从graphql发送授权请求到Python API,以便我可以与Python API通信。 在这个请求中,我需要发送用户的用户名和密码与Authorization标题和接收令牌将用于进一步沟通。 我不知道如何发送这个请求。 我已经创build了模式来进行通信,但是不知道如何添加这个部分。 这是我的代码的其余部分: Schema.js import { GraphQLSchema, GraphQLObjectType, GraphQLString, } from 'graphql'; import fetch from 'node-fetch'; const BASE_URL = 'http://localhost:9000/api'; function getUserByURL(relativeURL) { return fetch(`${BASE_URL}${relativeURL}`) .then(res => res.json()) .then(json => json.user) } const UserType = new GraphQLObjectType({ name: 'User', description: '…', fields: () => ({ firstName: { type: GraphQLString, resolve: (user) […]

错误:读取ECONNRESET,同时从nodejs运行pythonsubprocess

我在从节点js在EC2 Ubuntu上运行pythonsubprocess时出现错误。 生成的subprocess永远不会被node.js调用,但是在本地工作上完美的工作。 我们最初得到一个EPIPE错误,直到我们使用'sudo apt-get install libfontconfig',然后在下面产生这个错误: events.js:160 throw er; // Unhandled 'error' event ^ //error Error: read ECONNRESET at exports._errnoException (util.js:1020:11) at Pipe.onread (net.js:568:26) //child process urlCrawlJob(hostname, pageCounter+1, accessToken); //recursive calling of the function var process = SPAWN('python', [PATH.join(__dirname,"../pyScripts/crawler.py")]), data = body.customers; dataString = ''; console.log(`Spawned child pid: ${process.pid}`); process.stdout.on('error', function (err) { console.log('stdout […]

NovaExchange API:将Python代码转换为NodeJS

我正在为NODEJS编写一个API,但novaexchange站点上提供的示例是用Python编写的,因此我很难在NodeJS中编写相应的代码。 帮助将不胜感激。 代码写在Python中https://www.novaexchange.com/remote/faq/ #!/usr/bin/python import time import hmac import hashlib import base64 import requests # https://novaexchange.com/remote/faq/ API_KEY = "YOUR_API_KEY" API_SECRET = "YOUR_API_SECRET" public_set = set([ "markets", "market/info", "market/orderhistory", "market/openorders" ]) # optional private_set = set([ "getbalances", "getbalance", "getdeposits", "getwithdrawals", "getnewdepositaddress", "getdepositaddress", "myopenorders", "myopenorders_market", "cancelorder", "withdraw", "trade", "tradehistory", "getdeposithistory", "getwithdrawalhistory", "walletstatus" ]) url = "https://novaexchange.com/remote/v2/" def […]

任何队列工作者使用node.js而不是其他语言的好处?

我有任何使用Node.js的任务队列工人,而不是任何其他语言,如PHP / Python / Ruby的优势吗? 我想学习Redis的简单的任务队列任务,如发送大量的电子邮件,不想让用户等待build立连接等。 所以问题是:node.js的asynchronous性质在这种情况下有帮助还是没用? PS我知道节点比任何这种语言在内存消耗和计算上都要快,因为有效的V8引擎,也许有可能赢得这个领域?

什么因素导致数据在python(或python / node.js)的套接字中不通过?

(关于改写问题的build议?) 我通过一个客户端/服务器模式的套接字发送数据。 当我运行python(在pycharms)接收端的输出不会得到数据。 但是,当我使用重新运行的图标(在pycharms)数据通过。 我对这种行为感到困惑,并且不知道该问什么,除了告诉你我所观察到的。 这是客户端代码。 它正在与服务器安装与net (node.js) client.py import socket // python version 2.7.* if __name__ == "__main__": client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect(('127.0.0.1', 7000)) client.sendall("test data to transmit") data = client.recv(50) client.close() print 'Received', repr(data) server.js var net = require('net'); // node v0.10.21 (latest) var PYTHON = {HOST :'127.0.0.1', PORT :7000}; net.createServer(function(socket) { console.log('CONNECTION […]

使用node-python从python下载的web应用程序执行python脚本?

我为某些数值分析主题编写了Python脚本,因此我想用任何Java脚本库以很好的方式绘制它们。 所以,我了解了python-node,并在该站点显示了一些简要的doc信息: var python = require('node-python'); var os = python.import('os'); // nodejs stuff var path = require('path'); assert(os.path.basename(os.getcwd()) == path.basename(process.cwd())) 但是,我怎么才能开始真正做python ,导入python库,运行python脚本等?

primefaces编辑器:node-gyp重build崩溃

我正在尝试安装使用node-gyp的primefaces包。 但每次都会崩溃。 这里是apm输出: Installing autocomplete-clang to /home/lars/.atom/packages ✗ > runas@1.0.1 install /tmp/apm-install-dir-11499-22706-1lgjxbx/node_modules/autocomplete-clang/node_modules/clang-flags/node_modules/pathwatcher/node_modules/runas > node-gyp rebuild > runas@0.5.4 install /tmp/apm-install-dir-11499-22706-1lgjxbx/node_modules/autocomplete-clang/node_modules/snippets/node_modules/pathwatcher/node_modules/runas > node-gyp rebuild npm http GET https://registry.npmjs.org/underscore-plus npm http GET https://registry.npmjs.org/clang-flags npm http 304 https://registry.npmjs.org/underscore-plus npm http 304 https://registry.npmjs.org/clang-flags npm http GET https://registry.npmjs.org/underscore npm http GET https://registry.npmjs.org/pathwatcher npm http GET https://registry.npmjs.org/async npm http GET https://registry.npmjs.org/emissary npm […]

在同一个应用程序中打开Python和Nodejs

我正在构build一个Django项目,在Openshift中,我有一个Python 2.7和Mysql 5.5盒式磁带的应用程序。 我也想用bower来pipe理客户端软件包,但是bower具有npm和Node的依赖关系。 在Openshift中,我安装了npm,但是我没有Node,所以我不能安装bower。 我如何在openshift中安装Nodejs? 注意:我在openshift中没有sudo权限。 谢谢。

准备一个复杂的Python项目提交到启动板

我试图把自己的头围绕在整个PPA的事情上,似乎每个人都是这样做的。 让我们来看一个像http://bokeh.pydata.org/这样的项目,它有一个node.js的依赖关系,并且把它做成一个.deb。 按照这个 指南 ,在这里的各种职位,我试图用stdeb来做到这一点: pypi-download bokeh tar xfz bokeh-0.7.0.tar.gz cd bokeh-0.7.0/bokehjs/ npm install grunt build cd .. python3 setup.py –command-packages=stdeb.command sdist_dsc 输出的结尾是 dh clean –with python3 –buildsystem=python_distutils dh_testdir -O–buildsystem=python_distutils debian/rules override_dh_auto_clean make[1]: Entering directory `/home/emre/Desktop/bokeh-0.7.0/deb_dist/bokeh-0.7.0' python3 setup.py clean -a /home/emre/Desktop/bokeh-0.7.0/deb_dist/bokeh-0.7.0/bokehjs ERROR: Cannot install BokehJS: files missing in `./bokehjs/build`. Please build BokehJS by running setup.py […]

django通过节点服务器和socket.io将消息保存到数据库

我有节点服务器: var http = require('http'); var server = http.createServer().listen(4000); var io = require('socket.io').listen(server); var cookie_reader = require('cookie'); var querystring = require('querystring'); var redis = require('redis'); var sub = redis.createClient(); //Subscribe to the Redis chat channel sub.subscribe('chat'); //Configure socket.io to store cookie set by Django io.use(function(){ io.set('authorization', function(data, accept){ if(data.headers.cookie){ data.cookie = cookie_reader.parse(data.headers.cookie); return accept(null, true); […]