my-package-name
├── my_module_name
│ └── __init__.py
├── LICENSE.txt
├── README.rst
├── requirements.txt
└── pyproject.toml
- Create a Python package name which is ideally all lower case with no dashes but may contain dashes (but not underscores)
#!/bin/bash | |
if [ -z "$1" -o "$1" = "mount" ]; then | |
action=mount | |
elif [ "$1" = "umount" ]; then | |
action=umount | |
else | |
echo "missing action" | |
exit 1 | |
fi |
my-package-name
├── my_module_name
│ └── __init__.py
├── LICENSE.txt
├── README.rst
├── requirements.txt
└── pyproject.toml
from __future__ import unicode_literals | |
import logging | |
import json | |
logger = logging.getLogger(__name__) | |
logging.getLogger().setLevel(logging.INFO) | |
class PythonObjectEncoder(json.JSONEncoder): | |
"""Custom JSON Encoder that allows encoding of un-serializable objects |
import boto3 | |
def get_paginated_results(product, action, key, credentials=None, args=None): | |
args = {} if args is None else args | |
credentials = {} if credentials is None else credentials | |
return [y for sublist in [x[key] for x in boto3.client( | |
product, **credentials).get_paginator(action).paginate(**args)] | |
for y in sublist] |
try: | |
import xmlrpclib | |
except ImportError: | |
import xmlrpc.client as xmlrpclib | |
client = xmlrpclib.ServerProxy('https://pypi.python.org/pypi') | |
packages = client.list_packages() | |
total = len(packages) | |
dashes = len([x for x in packages if '-' in x]) |
def parse_arn(arn): | |
# http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html | |
elements = arn.split(':') | |
result = {'arn': elements[0], | |
'partition': elements[1], | |
'service': elements[2], | |
'region': elements[3], | |
'account': elements[4] | |
} | |
if len(elements) == 7: |
#!/usr/bin/env python | |
import ConfigParser | |
import argparse | |
import logging | |
import os | |
def type_loglevel(level): | |
try: | |
result = getattr(logging, level.upper()) |
If you git push
, find the problem, then do a git pull
, you're in no man's land
If you've been able to resist the urge to git pull
, then merely do a
git pull --rebase
which will fix this