Skip to content

Instantly share code, notes, and snippets.

Avatar
🎄
Sticking packages under the pypi tree.....

Sorin Sbarnea ssbarnea

🎄
Sticking packages under the pypi tree.....
View GitHub Profile
@ssbarnea
ssbarnea / test_ansi.py
Created October 26, 2011 16:18
ANSI support detection code for Python.
View test_ansi.py
#!/usr/bin/env python
import sys, os, time, platform
sample_ansi = '\x1b[31mRED' + '\x1b[33mYELLOW' + '\x1b[32mGREEN' + '\x1b[35mPINK' + '\x1b[0m' + '\n'
for handle in [sys.stdout, sys.stderr]:
if (hasattr(handle, "isatty") and handle.isatty()) or \
('TERM' in os.environ and os.environ['TERM']=='ANSI'):
if platform.system()=='Windows' and not ('TERM' in os.environ and os.environ['TERM']=='ANSI'):
@ssbarnea
ssbarnea / keytool-trust
Created October 4, 2012 13:14
Bash script that installs SSL certificates from different services to JVMs.
View keytool-trust
#!/bin/bash
REMHOST=$1
REMPORT=${2:-443}
CACERTS=$3
KEYSTORE_PASS=changeit
KEYTOOL=keytool
# /etc/java-6-sun/security/cacerts
View test.py
#!/usr/bin/env python
import ctypes
import getpass
import os
import sys
import subprocess
import pytest
import platform
import shutil
import warnings
View playbook.yml
---
- name: cleanup
hosts: localhost
gather_facts: false
tasks:
- name: Cleanup
debug:
msg: "Doing cleanup"
- name: Foo
View ruff-settings.txt
Resolved settings for: "/Users/ssbarnea/c/a/ansible-lint/.projects/ansible-compat/src/ansible_compat/__init__.py"
Settings path: "/Users/ssbarnea/c/a/ansible-lint/.projects/ansible-compat/pyproject.toml"
Settings {
rules: RuleTable {
enabled: {
MixedSpacesAndTabs,
MultipleImportsOnOneLine,
ModuleImportNotAtTopOfFile,
MultipleStatementsOnOneLineColon,
MultipleStatementsOnOneLineSemicolon,
@ssbarnea
ssbarnea / capture.py
Last active March 30, 2023 11:18
Script that captures both stdout and stderr in a way that works for subprocesses, while still being able to use rich own console to use original streams.
View capture.py
from rich.console import Console
from subprocess import run
import tempfile
import sys
from contextlib import redirect_stdout, redirect_stderr
# If we do not pass file=sys.stdout explicitly, rich output will also be
# captured by the context manager.
console = Console(file=sys.stdout)
console_err = Console(file=sys.stderr, stderr=True)
View gist:6c2db6451cd0ec20d12356391b8d9dbf
cd ~/.pyenv/versions
find . -name __pycache__
./3.10.6/lib/python3.10/encodings/__pycache__
./3.10.6/lib/python3.10/distutils/tests/__pycache__
./3.10.6/lib/python3.10/distutils/__pycache__
./3.10.6/lib/python3.10/distutils/command/__pycache__
./3.10.6/lib/python3.10/zoneinfo/__pycache__
./3.10.6/lib/python3.10/ctypes/test/__pycache__
./3.10.6/lib/python3.10/ctypes/__pycache__
View pre-commit.log
### version information
```
pre-commit version: 3.0.1
git --version: git version 2.39.1
sys.version:
3.11.1 (main, Dec 23 2022, 09:28:24) [Clang 14.0.0 (clang-1400.0.29.202)]
sys.executable: /Users/ssbarnea/.local/pipx/venvs/pre-commit/bin/python
os.name: posix
sys.platform: darwin
View tox-lock.log
$ tox -vvv --exit-and-dump-after 40 -e py
ROOT: 53 D setup logging to NOTSET on pid 67224 [tox/report.py:221]
ROOT: 99 W will run in automatically provisioned tox, host /Users/ssbarnea/.pyenv/versions/3.11-dev/bin/python3.11 is missing [requires (has)]: tox>=4.2.6 (4.2.2) [tox/provision.py:124]
.pkg: 111 I find interpreter for spec PythonSpec(path=/Users/ssbarnea/.pyenv/versions/3.11-dev/bin/python3.11) [virtualenv/discovery/builtin.py:56]
.pkg: 111 I proposed PythonInfo(spec=CPython3.11.0.final.0-64, exe=/Users/ssbarnea/.pyenv/versions/3.11-dev/bin/python3.11, platform=darwin, version='3.11.0+ (heads/3.11:4cd5ea62ac, Oct 25 2022, 18:19:49) [Clang 14.0.0 (clang-1400.0.29.102)]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:63]
.pkg: 111 D accepted PythonInfo(spec=CPython3.11.0.final.0-64, exe=/Users/ssbarnea/.pyenv/versions/3.11-dev/bin/python3.11, platform=darwin, version='3.11.0+ (heads/3.11:4cd5ea62ac, Oct 25 2022, 18:19:49) [Clang 14.0.0 (clang-1400.0.29.102)]', encoding_fs_io=utf-8-utf-8
View setuptools-scm.log
ssbarnea@m1: ~/c/a/ansible-lint fix/schema-cache ⚡
$ SETUPTOOLS_SCM_DEBUG=1 tox -e pkg
pkg: commands[0]> .tox/pkg/bin/python -c 'import os.path, shutil, sys; dist_dir = os.path.join("/Users/ssbarnea/c/a/ansible-lint", "dist"); os.path.isdir(dist_dir) or sys.exit(0); print("Removing {!s} contents...".format(dist_dir), file=sys.stderr); shutil.rmtree(dist_dir)'
Removing /Users/ssbarnea/c/a/ansible-lint/dist contents...
pkg: commands[1]> .tox/pkg/bin/python -m build --outdir /Users/ssbarnea/c/a/ansible-lint/dist/ /Users/ssbarnea/c/a/ansible-lint
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools >= 63.0.0, setuptools_scm[toml] >= 7.0.5, wheel)
* Getting build dependencies for sdist...
finalize hook {'name': None, 'version': None, 'author': None, 'author_email': None, 'maintainer': None, 'maintainer_email': None, 'url': None, 'license': None, 'description': None, 'long_description': None, 'keywords': None, 'platforms': None, 'classifiers': None, 'download_url': No