pfctdayelise + python   215

Python Patterns
It’s time for me to start writing up, in one place, my ideas about Python programming patterns that are currently scattered across all of my Python conference talks and writing.

One reason is that, after all of these years, my Python Design Patterns talk from 2012 is still one of my most popular — despite conference video problems that forced me to cut 20 minutes of material! Another is that written material is easier for other programmers to search, browse, and reference, and can be corrected and improved as time goes on.
python  designpatterns 
6 days ago by pfctdayelise
Ned Batchelder: Why your mock doesn’t work
stupid importing stuff that bites you every time
python  testing 
6 weeks ago by pfctdayelise
Python - Hashids
Hashids is a small open-source library that generates short, unique, non-sequential ids from numbers.

It converts numbers like 347 into strings like “yr8”, or array of numbers like [27, 986] into “3kTMd”.

You can also decode those ids back. This is useful in bundling several parameters into one or simply using them as short UIDs.
python 
7 weeks ago by pfctdayelise
Pengutronix - Labgrid
Labgrid is an embedded board control python library with a focus on testing, development and general automation. It includes a remote control layer to control boards connected to other hosts.

The idea behind labgrid is to create an abstraction of the hardware control layer needed for testing of embedded systems, automatic software installation and automation during development. Labgrid itself is not a testing framework, but is intended to be combined with pytest (and additional pytest plugins).
pytest  python  testing  embedded 
9 weeks ago by pfctdayelise
PyOxidizer — PyOxidizer 0.1 documentation
From a very high level, PyOxidizer is a tool for packaging and distributing Python applications. The over-arching goal of PyOxidizer is to make this (often complex) problem space simple so application maintainers can focus on building quality applications instead of toiling with build systems and packaging tools.

On a lower, more technical level, PyOxidizer has a command line tool - pyoxidizer - that is capable of building binaries (executables or libraries) that embed a fully-functional Python interpreter plus Python extensions and modules in a single binary. Binaries produced with PyOxidizer are highly portable and can work on nearly every system without any special requirements like containers, FUSE filesystems, or even temporary directory access. On Linux, PyOxidizer can produce executables that are fully statically linked and don’t even support dynamic loading.

The Oxidizer part of the name comes from Rust: binaries built with PyOxidizer are compiled from Rust and Rust code is responsible for managing the embedded Python interpreter and all its operations. But the existence of Rust should be invisible to many users, much like the fact that CPython (the official Python distribution available from www.python.org) is implemented in C. Rust is simply a tool to achieve an end goal (albeit a rather effective and powerful tool).
python  packaging  rust 
10 weeks ago by pfctdayelise
keeppythonweird/catinabox: Intro to Testing and Test Automation in Python
This repo holds a tutorial which will walk you through adding unit tests, exploring these features of unit testing in general and pytest in particular:

Basic unit testing
Observing test success and coverage using Travis CI and coveralls.
python  testing  pytest  tutorial 
may 2019 by pfctdayelise
Visual Studio Code, Python and pipenv - Benjamin Pack
I’ve been doing some experimenting with pipenv to simplify my nascent Python programming workflows and also with Visual Studio Code as a cross-platform code editor. So naturally I want VS Code to use the python version from my pipenv-based virtual environment (as one does). I also want the compiled .pyc files to not show up in the explorer view. Fortunately, both of these things can be accomplished by overriding some default VS Code settings.
pipenv  python  vscode 
may 2019 by pfctdayelise
PyVISA: Control your instruments with Python — PyVISA 1.10.0.dev0 documentation
PyVISA: Control your instruments with Python

PyVISA is a Python package that enables you to control all kinds of measurement devices independently of the interface (e.g. GPIB, RS232, USB, Ethernet). As an example, reading self-identification from a Keithley Multimeter with GPIB number 12 is as easy as three lines of Python code:

>>> import visa
>>> rm = visa.ResourceManager()
>>> rm.list_resources()
('ASRL1::INSTR', 'ASRL2::INSTR', 'GPIB0::12::INSTR')
>>> inst = rm.open_resource('GPIB0::12::INSTR')
>>> print(inst.query("*IDN?"))
(That’s the whole program; really!) It works on Windows, Linux and Mac; with arbitrary adapters (e.g. National Instruments, Agilent, Tektronix, Stanford Research Systems).

General overview
The programming of measurement instruments can be real pain. There are many different protocols, sent over many different interfaces and bus systems (e.g. GPIB, RS232, USB, Ethernet). For every programming language you want to use, you have to find libraries that support both your device and its bus system.

In order to ease this unfortunate situation, the Virtual Instrument Software Architecture (VISA) specification was defined in the middle of the 90ies. VISA is a standard for configuring, programming, and troubleshooting instrumentation systems comprising GPIB, VXI, PXI, Serial, Ethernet, and/or USB interfaces.

Today VISA is implemented on all significant operating systems. A couple of vendors offer VISA libraries, partly with free download. These libraries work together with arbitrary peripherical devices, although they may be limited to certain interface devices, such as the vendor’s GPIB card.

The VISA specification has explicit bindings to Visual Basic, C, and G (LabVIEW’s graphical language). Python can be used to call functions from a VISA shared library (.dll, .so, .dylib) allowing to directly leverage the standard implementations. In addition, Python can be used to directly access most bus systems used by instruments which is why one can envision to implement the VISA standard directly in Python (see the PyVISA-Py project for more details). PyVISA is both a Python wrapper for VISA shared libraries but can also serve as a front-end for other VISA implementation such as PyVISA-Py.
python  hardware  testing 
may 2019 by pfctdayelise
kadirpekel/hammock: rest like a boss
Hammock is a fun module lets you deal with rest APIs by converting them into dead simple programmatic APIs. It uses popular requests module in backyard to provide full-fledged rest experience.
python  rest  api 
may 2019 by pfctdayelise
ithaka/apiron: apiron is a Python package that helps you cook a tasty client for RESTful APIs. Just don't wash it with SOAP.
Gathering data from multiple services has become a ubiquitous task for web application developers. The complexity can grow quickly: calling an API endpoint with multiple parameter sets, calling multiple API endpoints, calling multiple endpoints in multiple APIs. While the business logic can get hairy, the code to interact with those APIs doesn't have to.

apiron provides declarative, structured configuration of services and endpoints with a unified interface for interacting with them.
python  rest  api 
may 2019 by pfctdayelise
GitHub - torfsen/python-systemd-tutorial: A tutorial for writing a systemd service in Python
Writing a systemd Service in Python
Many Linux distributions use systemd to manage the system's services (or daemons), for example to automatically start certain services in the correct order when the system boots.

Writing a systemd service in Python turns out to be easy, but the complexity of systemd can be daunting at first. This tutorial is intended to get you started.

When you feel lost or need the gritty details, head over to the systemd documentation, which is pretty extensive. However, the docs are distributed over several pages, and finding what you're looking for isn't always easy. A good place to look up a particular systemd detail is systemd.directives, which lists all the configuration options, command line parameters, etc., and links to their documentation.

Aside from this README.md file, this repository contains a basic implementation of a Python service consisting of a Python script (python_demo_service.py) and a systemd unit file (python_demo_service.service).

The systemd version we're going to work with is 229, so if you're using a different version (see systemctl --version) then check the systemd documentation for things that may differ.
linux  service  python 
february 2019 by pfctdayelise
Gaia - Build powerful pipelines in any programming language.
Automation platform of the future

Automation processes and requirements have developed rapidly in recent years. Cloud, SaaS, PaaS, AaaS, Kubernetes, Docker, and many more technologies were invented to simplify the complexity and management of huge IT applications. Communication with external APIs and services for CI/CD is simply essential nowadays and hard to do right with simple configuration specs.

Gaia is the next evolution of automation platforms whose goal is to provide full flexibility and performance for today's CI/CD, but basically any automation workflow imaginable.
Enables DevOps

DevOps becomes more and more important and many developers are scared of this word because it usually implies writing endless lines of YAML/JSON configuration files to automate complex automation tasks.

Gaia requires no YAML/JSON or any other configuration spec to write automation workflows. An automation workflow (we named it pipeline) can be written in any programming language and adding it to Gaia usually takes a few seconds. Once a pipeline has been added, Gaia automatically detects changes and rebuilds your pipeline automatically.
Efficient and super fast
Gaia has been from the ground up developed with the goal to be ultra lightweight, efficient, super fast and developer-first. It's core is written in Go and the pipeline communication is based on googles battle-hardened gRPC which uses HTTP/2. The Unix philosophy (simple, modular and composable) is and will always be the base principle for Gaia.
Build by and for operators

Gaia is one self-contained binary which can be started without any configuration. Just download, unarchive and start it. We also provide various docker images ready to pull. You prefer to have all your tools running in Kubernetes? Don't worry, we also provide a helm chart.

Get started now and setup Gaia within seconds, develop your first pipeline in 5-10 minutes.
devops  python  opensource 
january 2019 by pfctdayelise
shiv 🔪 — shiv documentation
Shiv is a command line utility for building fully self contained Python zipapps as outlined in PEP 441 but with all their dependencies included!

Shiv’s primary goal is making distributing Python applications fast & easy.
python 
january 2019 by pfctdayelise
Taurus
Kind of open source?? not sure where the bug tracker is. can run pytest tests.
performance  testing  python  opensource 
january 2019 by pfctdayelise
icecream Sweet and creamy print debugging.
IceCream is a little library for sweet and creamy debugging.

Do you ever use print() or log() to debug your code? Of course you do. IceCream, or ic for short, makes print debugging a little sweeter.

IceCream is well tested, permissively licensed, and supports Python 2, Python 3, PyPy2, and PyPy3.
Ice Cream with Toppings (Arguments)

Have you ever printed variables or expressions to debug your program? If you've ever typed something like

print(foo('123'))

or the more thorough

print("foo('123')", foo('123'))

then ic() is here to help. With arguments, ic() inspects itself and prints both its own arguments and the values of those arguments.

from icecream import ic

def foo(i):
return i + 333

ic(foo(123))

Prints

ic| foo(123): 456

Similarly,

d = {'key': {1: 'one'}}
ic(d['key'][1])

class klass():
attr = 'yep'
ic(klass.attr)

Prints

ic| d['key'][1]: 'one'
ic| klass.attr: 'yep'

Just give ic() a variable or expression and you're done. Easy.
python  debugging 
june 2018 by pfctdayelise
pytudes
"An étude (a French word meaning study) is an instrumental musical composition, usually short, of considerable difficulty, and designed to provide practice material for perfecting a particular musical skill." — Wikipedia

This project contains pytudes—Python programs for perfecting programming skills.

Some are in Jupyter (IPython) notebooks, some in .py files.
programming  python  practice 
february 2018 by pfctdayelise
walrus — walrus 0.5.1 documentation
Python utilities for working with Redis:

container classes
autocomplete
cache
full-text search
graph store
rate limiting
active-record models (secondary indexes, full-text search)
locks
more? more!

My hope is that walrus saves you time developing your application by providing useful Redis-specific components. If you have an idea for a new feature, please don’t hesitate to tell me about it.
python  redis 
february 2018 by pfctdayelise
Deploying Python Web Applications with nginx and uWSGI Emperor | Chris Warrick
You’ve just written a great Python web application. Now, you want to share it with the world. In order to do that, you need a server, and some software to do that for you.
The following is a comprehensive guide on how to accomplish that, on multiple Linux-based operating systems, using nginx and uWSGI Emperor. It doesn’t force you to use any specific web framework — Flask, Django, Pyramid, Bottle will all work. Written for Ubuntu, Debian, Fedora, CentOS and Arch Linux (should be helpful for other systems, too). Now with an Ansible Playbook.
python  ansible  ubuntu  debian  nginx  uwsgi  webdev 
may 2017 by pfctdayelise
Sentry Server – Sentry Documentation
Stop hoping your users will report errors
Sentry’s real-time error tracking gives you insight into production deployments and information to reproduce and fix crashes.

You can pay for sentry.io or you can also set up the server yourself for "on premises" use.
python  monitoring 
may 2017 by pfctdayelise
The Book
"Test-Driven Web Development with Python" aims to teach TDD for web programming. It uses a concrete example -- the development of a website, from scratch -- to explain the TDD metholology and how it applies to building web applications. It covers the Selenium browser-automation tool, unit testing, mocking, and interacting with Web technologies from the basics of static content, database integration, throught the inescapable JavaScript, and onto more advanced (and trendy) topics like NoSQL, websockets and Async programming.
python  django  testing 
march 2017 by pfctdayelise
mnot/redbot @ GitHub
"RED checks HTTP resources to see how they use HTTP, makes suggestions, and finds common protocol mistakes."

Public instance, can also be installed locally.
python  http 
may 2016 by pfctdayelise
pgcli
Pgcli is a command line interface for Postgres with auto-completion and syntax highlighting.
postgres  python  opensource 
november 2015 by pfctdayelise
re:dash
Open Soure Data Collaboration Platform
Connect to any data source, visualize your data and share it with anyone!
opensource  python  datavis 
november 2015 by pfctdayelise
« earlier      
per page:    204080120160

related tags

abc  alm  android  ansible  apache  api  async  AWS  blog  books  briannalaugher  browser  bugtracker  bzr  caching  cc-by-sa  celery  cffsw  charts  CI  client  code  comments  compare  compling  conference  conferences  contracttesting  cool  data  database  datamining  datavis  debian  debugging  decorators  deployment  designpatterns  developers  devops  django  docker  documentation  dreamhost  eclipse  education  emacs  email  embedded  emoji  evaluation  events  examples  excel  fabric  flask  forms  funny  games  garmin  geekculture  geekfeminism  generators  geo  geospatial  github  glitch  graphite  graphs  gui  hackathons  hardware  hg  howto  html  http  hypothesis  i18n  identica  interesting  internode  interview  ironpython  jaiku  javascript  jupyter  language  languages  LCA  LCA2010  leaflet  linguistics  linter  linux  literateprogramming  machinelearning  mailman  maps  matplotlib  mediawiki  melbourne  metrics  microservices  Microsoft  mod_wsgi  monitoring  mono  nginx  NLP  nltk  notebook  ocr  opendap  opensource  oracle  packaging  pandas  performance  perl  php  pip  pipenv  podcast  postgres  practice  pretty  profiling  programming  prolog  PSI  pyblosxom  pyconau  pydap  pygame  pylint  pyqt  pytest  python  python3  quality  redis  regexp  rest  restructuredtext  rss  ruby  rust  screencast  screenscraping  search  security  service  shiny  site  software  softwaredev  spain  spanish  sqlite  static  statsd  swagger  t10n  teaching  testing  text  tutorial  twitter  ubuntu  unicode  useful  uwsgi  versioncontrol  video  vscode  vsts  wasm  weatherforecasts  web  web-based  web.py  web2.0  web2py  webaccess  webdesign  webdev  websockets  wiki  wikipedia  women  xml  Y  zookeepr 

Copy this bookmark:



description:


tags: