python有哪些常用的package_Python - 常用Packages

1. PyInstaller - 打包Python程序

$ pip install pyinstaller

$ pyinstaller yourprogram.py

38a8d852f06e

image.png

2. Locust - 测试工具,可完成压力测试、功能测试等

test script

from locust import HttpLocust, TaskSet, task

class UserBehavior(TaskSet):

def on_start(self):

""" on_start is called when a Locust start before any task is scheduled """

self.login()

def on_stop(self):

""" on_stop is called when the TaskSet is stopping """

self.logout()

def login(self):

self.client.post("/login", {"username":"ellen_key", "password":"education"})

def logout(self):

self.client.post("/logout", {"username":"ellen_key", "password":"education"})

@task(2)

def index(self):

self.client.get("/")

@task(1)

def profile(self):

self.client.get("/profile")

class WebsiteUser(HttpLocust):

task_set = UserBehavior

min_wait = 5000

max_wait = 9000

run for test

$ locust -f locust_files/my_locust_file.py --host=http://example.com

open http://127.0.0.1:8089 to start and analyse test results

38a8d852f06e

image.png

`

3. luigi - 任务调度系统

3.1. 概述

Luigi is a Python (2.7, 3.6, 3.7 tested) package that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization, handling failures, command line integration, and much more.

38a8d852f06e

image.png

38a8d852f06e

image.png

3.2. demo

3.2.1. hello world

hello_world.py

import luigi

class HelloWorldTask(luigi.Task):

task_namespace = 'examples'

def run(self):

print("{task} says: Hello world!".format(task=self.__class__.__name__))

if __name__ == "__main__":

luigi.run(['examples.HelloWorldTask', '--workers', '1', '--local-scheduler'])

run

$ python hello_world.py

...

===== Luigi Execution Summary =====

Scheduled 1 tasks of which:

* 1 ran successfully:

- 1 examples.HelloWorldTask()

This progress looks :) because there were no failed tasks or missing dependencies

===== Luigi Execution Summary =====

3.2.2. foo-bar

foo.py

from __future__ import print_function

import time

import luigi

class Foo(luigi.WrapperTask):

task_namespace = 'examples'

def run(self):

print("Running Foo")

def requires(self):

for i in range(10):

yield Bar(i)

class Bar(luigi.Task):

task_namespace = 'examples'

num = luigi.IntParameter()

def run(self):

time.sleep(1)

self.output().open('w').close()

def output(self):

"""

Returns the target output for this task.

:return: the target output for this task.

:rtype: object (:py:class:`~luigi.target.Target`)

"""

time.sleep(1)

return luigi.LocalTarget('/tmp/bar/%d' % self.num)

if __name__ == '__main__':

luigi.run()

run

$ python foo.py examples.Foo

...

===== Luigi Execution Summary =====

Scheduled 1 tasks of which:

* 1 complete ones were encountered:

- 1 examples.Foo()

Did not run any tasks

This progress looks :) because there were no failed tasks or missing dependencies

===== Luigi Execution Summary =====

3.3. 参考

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
make /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/xproto.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/bigreq.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/xc_misc.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/composite.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/damage.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/dpms.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/dri2.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/glx.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/randr.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/record.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/render.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/res.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/screensaver.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/shape.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/shm.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/sync.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/xevie.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/xf86dri.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/xfixes.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/xinerama.xml /usr/bin/python ./c_client.py -p //usr/lib/python3.8/site-packages //usr/share/xcb/xinput.xml Traceback (most recent call last): File "./c_client.py", line 1039, in <module> module.register() File "/usr/lib/python2.7/dist-packages/xcbgen/state.py", line 93, in register matcher.execute(self, self.namespace) File "/usr/lib/python2.7/dist-packages/xcbgen/matcher.py", line 115, in execute funcs[elt.tag](elt, module, namespace) KeyError: 'eventstruct' make: *** [Makefile:1018: xinput.c] Error 1
05-24

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值