pyjsonrpc模块使用
pyjsonrpc模块的远程过程调用方法。
# -*- coding:utf-8 -*-
#!/usr/bin/env python2.7
# @Author : tianbao
# @Contact : gmu1592618@gmail.com
# @Time : 2018/7/4 21:49
# @File : aactest.py
# @Software: PyCharm
import pyjsonrpc http_client = pyjsonrpc.HttpClient(
url = "http://example.com/jsonrpc",
username = "Username",
password = "Password"
)
# 第一种调用方法
print http_client.call("add", 1, 2)
# Result: 3 # 第二种调用方法
# It is also possible to use the *method* name as *attribute* name.
print http_client.add(1, 2)
# Result: 3 # 没有返回值
# Notifications send messages to the server, without response.
http_client.notify("add", 3, 4)
client
# -*- coding:utf-8 -*-
#!/usr/bin/env python2.7
# @Author : tianbao
# @Contact : gmu1592618@gmail.com
# @Time : 2018/7/4 21:49
# @File : aastest.py
# @Software: PyCharm
import pyjsonrpc class RequestHandler(pyjsonrpc.HttpRequestHandler): @pyjsonrpc.rpcmethod
def add(self, a, b):
"""Test method"""
return a + b # Threading HTTP-Server
http_server = pyjsonrpc.ThreadingHttpServer(
server_address = ('localhost', 8080), # 监听地址
RequestHandlerClass = RequestHandler
)
print "Starting HTTP server ..."
print "URL: http://localhost:8080"
http_server.serve_forever() # 启动
server
#!/usr/bin/env python
# -*- coding: utf-8 -*- import pygtk
pygtk.require('2.0')
import gtk
import sys
import os
import random
import gobject from debug import log
from cusdialog import DialogWith1Button class A(object):
def __init__(self):
self.wait_times=0 btn1_dlg = DialogWith1Button(btn1_label="关闭")
btn1_dlg.set_label_text("正在启动,请稍候。。。")
# btn1_dlg.msg_dialog.set_transient_for(self.win) def wait_timeout(self,btn1_dlg, max_times):
self.wait_times += random.randint(1, 5)
if self.wait_times > max_times:
btn1_dlg.btn_ok.clicked()
return False
btn1_dlg.set_label_text("正在启动,请稍候。。。(%s%%)" %\
(self.wait_times*100/max_times,))
return True if __name__ == '__main__':
a=A() gobject.timeout_add(1000, a.wait_timeout, a.btn1_dlg, 100) a.btn1_dlg.run()
ptgtk记时器
from apscheduler.schedulers.blocking import BlockingScheduler
import datetime def aps_test():
print datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), '你好' scheduler = BlockingScheduler()
scheduler.add_job(func=aps_test, trigger='cron', second='*/5')
scheduler.start()
apscheduler定时器
pyjsonrpc模块使用的更多相关文章
- npm 私有模块的管理使用
你可以使用 NPM 命令行工具来管理你在 NPM 仓库的私有模块代码,这使得在项目中使用公共模块变的更加方便. 开始前的工作 你需要一个 2.7.0 以上版本的 npm ,并且需要有一个可以登陆 np ...
- node.js学习(三)简单的node程序&&模块简单使用&&commonJS规范&&深入理解模块原理
一.一个简单的node程序 1.新建一个txt文件 2.修改后缀 修改之后会弹出这个,点击"是" 3.运行test.js 源文件 使用node.js运行之后的. 如果该路径下没有该 ...
- ES6模块import细节
写在前面,目前浏览器对ES6的import支持还不是很好,需要用bable转译. ES6引入外部模块分两种情况: 1.导入外部的变量或函数等: import {firstName, lastName, ...
- Python标准模块--ContextManager
1 模块简介 在数年前,Python 2.5 加入了一个非常特殊的关键字,就是with.with语句允许开发者创建上下文管理器.什么是上下文管理器?上下文管理器就是允许你可以自动地开始和结束一些事情. ...
- Python标准模块--Unicode
1 模块简介 Python 3中最大的变化之一就是删除了Unicode类型.在Python 2中,有str类型和unicode类型,例如, Python 2.7.6 (default, Oct 26 ...
- Python标准模块--Iterators和Generators
1 模块简介 当你开始使用Python编程时,你或许已经使用了iterators(迭代器)和generators(生成器),你当时可能并没有意识到.在本篇博文中,我们将会学习迭代器和生成器是什么.当然 ...
- 自己实现一个javascript事件模块
nodejs中的事件模块 nodejs中有一个events模块,用来给别的函数对象提供绑定事件.触发事件的能力.这个别的函数的对象,我把它叫做事件宿主对象(非权威叫法),其原理是把宿主函数的原型链指向 ...
- 理解nodejs模块的scope
描述 原文档地址:https://docs.npmjs.com/misc/scope 所有npm模块都有name,有的模块的name还有scope.scope的命名规则和name差不多,同样不能有ur ...
- nodejs模块发布及命令行程序开发
前置技能 npm工具为nodejs提供了一个模块和管理程序模块依赖的机制,当我们希望把模块贡献出去给他人使用时,可以把我们的程序发布到npm提供的公共仓库中,为了方便模块的管理,npm规定要使用一个叫 ...
随机推荐
- UITextView的一些技巧
1.在指定位置插入字符串: NSMutableString *TextViewStr=[[NSMutableString alloc] initWithString:TextView.text ...
- JVM相关小结
对JVM中分层模型.垃圾回收期.垃圾回收算法趁着周末小结一下.有不对的地方,还请指正和讨论~ 1.JVM内存模型 2.JVM垃圾回收期 3.JVM垃圾回收算法 ------------------- ...
- Matlab时频图
[b,f,t]=specgram(data,nfft,Fs,window,numoverlap); imagesc(t,f,20*log10(abs(b))), axis xy, colormap(j ...
- JavaScript中实现继承
今天即兴研究了下JS,查阅了相关资料 ,发现Js中没有"子类"和"父类"的概念,也没有"类"(class)和"实例"(i ...
- C#中的new和override(转)
在衍生类中的方法上使用new和override关键字有何意义,可以通过一系列问题来找到答案.先看一段代码: 1 class Program 2 { 3 static void Main(string[ ...
- JavaScript library of crypto standards. 看源码
crypto-js - npm https://www.npmjs.com/package/crypto-js crypto-js/docs/QuickStartGuide.wiki <wiki ...
- mysql date函数相关用法整理(持续更新)
date_add(now(), INTERVAL 1 day) 增加一天 date_format(d,'%Y-%m-%d %T') 这里的d为datestamp类型,格式化成 yyyy-MM ...
- 《Linux 鸟哥私房菜》 第一部分 Linux文件、目录与磁盘格式
1.Linux就是内核层与系统调用接口层这2层.
- RANDOM 的用法
random 用法 1.利用RANDOM取随机数 shell有一个环境变量RANDOM,范围是0--32767 如果我们想要产生0-25范围内的数:$(($RANDOM%26),在$(()) 是可以省 ...
- 【Linux】服务器之间的免密登录脚本
在实际运维的过程中,经常需要用到免密登录,下面这个脚本实现服务器之间的免密登录,如下 比如,要实现A服务器与B.C.D服务器的免密登录,只需要将B.C.D服务器的IP地址写在serverlist.tx ...