4343 links
  • Arnaud's links
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
Links per page: 20 50 100
◄Older
page 4 / 5
Newer►
97 results tagged python x
  • thumbnail
    python - Print in terminal with colors? - Stack Overflow

    def print_format_table():
    """
    prints table of formatted text format options
    """
    for style in range(8):
    for fg in range(30,38):
    s1 = ''
    for bg in range(40,48):
    format = ';'.join([str(style), str(fg), str(bg)])
    s1 += '\x1b[%sm %s \x1b[0m' % (format, format)
    print(s1)
    print('\n')

    print_format_table()

    2017年11月17日 GMT+1 上午9:37:26 - permalink - archive.org - https://stackoverflow.com/questions/287871/print-in-terminal-with-colors
    color python terminal
  • thumbnail
    Apache Libcloud is a standard Python library that abstracts away differences among multiple cloud provider APIs | Apache Libcloud

    utopie ^^

    2017年11月17日 GMT+1 上午9:34:14 - permalink - archive.org - https://libcloud.apache.org/
    cloud lib python
  • Logging HOWTO — Python 3.6.2rc2 documentation

    python3 log to file AND stdout
    import logging
    logging.basicConfig(handlers=[logging.FileHandler('/var/log/runner/process1.log'),logging.StreamHandler()],format='%(asctime)s %(levelname)s %(message)s',level=logging.INFO)

    logging.info('foo')

    Encore mieux pour supporter le logrotate sans copytruncate :
    import logging.handlers
    logging.basicConfig(handlers=[logging.handlers.WatchedFileHandler('/var/log/worker/worker1.log'),logging.StreamHandler()],format='%(asctime)s %(levelname)s %(message)s',level=logging.INFO)

    /var/log/worker/*.log {
    monthly
    rotate 12
    compress
    delaycompress
    missingok
    notifempty
    create 644 root root
    }

    Python 2:

    import logging as loggingg

    logging = loggingg.getLogger('simple_example')
    logging.setLevel(loggingg.INFO)

    formatter = loggingg.Formatter('%(asctime)s %(levelname)s %(message)s')

    console_handler = loggingg.StreamHandler()
    console_handler.setLevel(loggingg.INFO)
    console_handler.setFormatter(formatter)

    file_handler = loggingg.FileHandler('/var/log/worker/worker3.log')
    file_handler.setLevel(loggingg.INFO)
    file_handler.setFormatter(formatter)

    logging.addHandler(console_handler)
    logging.addHandler(file_handler)

    2017年7月11日 GMT+2 上午10:05:21 * - permalink - archive.org - https://docs.python.org/3/howto/logging.html
    log logrotate python
  • Note: some draft about monitoring beanstalk applications health with boto3 python script
    import pprint
    p = pprint.PrettyPrinter(indent=4)
    p.pprint(x)

    or

    import pprint
    pprint.pformat(x)


    import logging
    import pprint
    logging.info(pprint.pformat(dict))



     $ cat monitor_beanstalk.py
    #!/bin/python

    import boto3
    import pprint
    pp = pprint.PrettyPrinter(indent=4)


    #List all env and status and instances health

    client = boto3.client('elasticbeanstalk')


    envs = client.describe_environments()['Environments']

    #pp.pprint(envs)


    for env in envs:
        print 'ApplicationName: {} EnvironmentName: {} Health: {} HealthStatus: {} Status: {}'.format(env['ApplicationName'].ljust(30),env['EnvironmentName'].ljust(30),env['Health'].ljust(10),env.get('HealthStatus', 'N/A').ljust(10),env['Status'].ljust(10))
        if (env['Health'] != 'Green') or (env.get('HealthStatus', 'N/A') != 'Ok' and env.get('HealthStatus', 'N/A') != 'N/A'):
            print '\nProblem'
            details = client.describe_environment_health(EnvironmentName=env['EnvironmentName'],AttributeNames=['All'])
            #pp.pprint(details)
            print details['Causes']
            print details['InstancesHealth']
            print '\n'
    2017年6月15日 GMT+2 上午11:12:05 * - permalink - archive.org - https://links.infomee.fr/?eFFzMg
    aws beanstalk boto pprint python
  • Note: find/sed equivalent in python

    for root, dirs, files in os.walk("folder"):
    for file in files:
    if file.endswith(".yml"):
    print(os.path.join(root, file))
    with open(os.path.join(root, file), "r") as sources:
    lines = sources.readlines()
    with open(os.path.join(root, file), "w") as sources:
    for line in lines:
    sources.write(re.sub(r'pattern', 'foo', line))

    2017年5月29日 GMT+2 下午2:15:06 - permalink - archive.org - https://links.infomee.fr/?Y803hg
    find python sed
  • https://pypi.python.org/pypi/awscli/json

    Add /json to pypi package url.. Magic!

    2017年5月4日 GMT+2 下午2:11:45 - permalink - archive.org - https://pypi.python.org/pypi/awscli/json
    pip python
  • Stupid Python Tricks: The KeyboardInterrupt Exception
    catching all exception in python
    import traceback

    for record in database:
        try:
            blabla
        except (KeyboardInterrupt, SystemExit):
            raise
        except Exception as e:
            # report error and proceed
            print(type(e).__name__)
            print(e)
            print(traceback.format_exc())

    Ne pas oublier de raise si on veut re-raise
           
    2017年4月21日 GMT+2 下午4:19:03 * - permalink - archive.org - http://effbot.org/zone/stupid-exceptions-keyboardinterrupt.htm
    exception python
  • Note: boto3 subnet sorted by name

    subnets = ec2.subnets.all()
    subnets_sorted = sorted(subnets, key=lambda k: k.tags[next(index for (index, d) in enumerate(k.tags) if d["Key"] == "Name")]['Value'])

    Well, my python level is not good enough to clearly understand this but my Google level was largely enough to build this

    2017年3月24日 GMT+1 下午4:02:34 - permalink - archive.org - https://links.infomee.fr/?Fn--jw
    aws boto boto3 python
  • Tutorial: Todo-List Application — Bottle 0.12.13 documentation

    Running Bottle with a different server

    As said above, the standard server is perfectly suitable for development, personal use or a small group of people only using your application based on Bottle. For larger tasks, the standard server may become a bottleneck, as it is single-threaded, thus it can only serve one request at a time.

    But Bottle has already various adapters to multi-threaded servers on board, which perform better on higher load. Bottle supports Cherrypy, Fapws3, Flup and Paste.

    If you want to run for example Bottle with the Paste server, use the following code:

    from bottle import PasteServer
    ...
    run(server=PasteServer)

    This works exactly the same way with FlupServer, CherryPyServer and FapwsServer.

    2017年3月2日 GMT+1 下午9:09:38 - permalink - archive.org - https://bottlepy.org/docs/stable/tutorial_app.html#server-setup
    bottle python
  • thumbnail
    logging - How to log into a file for a python & bottle web server? - Stack Overflow

    import logging
    logging.basicConfig(filename='log.txt', format=logging.BASIC_FORMAT)
    logging.error('OH NO!')
    try:
    raise Exception('Foo')
    except:
    logging.exception("Oops:")

    2017年3月2日 GMT+1 下午8:56:16 - permalink - archive.org - http://stackoverflow.com/questions/15444695/how-to-log-into-a-file-for-a-python-bottle-web-server
    bottle log python
  • Quickstart — Boto 3 Docs 1.4.0 documentation
    2016年9月29日 GMT+2 上午11:16:39 - permalink - archive.org - http://boto3.readthedocs.io/en/latest/guide/quickstart.html
    aws boto python
  • Kit SDK AWS pour Python

    Un sdk en python pour aws

    https://boto3.readthedocs.io/en/latest/guide/resources.html

    2016年8月16日 GMT+2 下午5:40:40 - permalink - archive.org - https://aws.amazon.com/fr/sdk-for-python/
    aws python sdk
  • The 10 Most Common Mistakes That Python Programmers Make | Toptal

    via sebsauvage

    2016年2月23日 GMT+1 上午9:57:51 - permalink - archive.org - http://www.toptal.com/python/top-10-mistakes-that-python-programmers-make
    common error python
  • Random writings and thoughts about Python: psutil 4.0.0 and how to get "real" process memory and environ in Python
    2016年2月18日 GMT+1 上午10:55:56 - permalink - archive.org - http://grodola.blogspot.com/2016/02/psutil-4-real-process-memory-and-environ.html
    memory ps psutil python
  • Notions de Python avancées • Tutoriels • Zeste de Savoir

    Un cours en français qui a l'air très bien. Via sametmax sur twitter

    2016年1月1日 GMT+1 上午10:21:09 - permalink - archive.org - http://zestedesavoir.com/tutoriels/954/notions-de-python-avancees/
    python
  • thumbnail
    RedisLabs/redis-migrate

    useful script to migrate redis server without downtime

    • http://boomboomboom.biz/blog/2013/09/07/migrate-redis-to-a-new-server-without-downtime/
    2015年11月9日 GMT+1 下午2:55:05 - permalink - archive.org - https://github.com/RedisLabs/redis-migrate
    migrate python redis
  • Cue/scales

    Pratique pour avoir des stat rapidement dans ses scripts python (si on n'a pas de stack graphite sous la main)

    2015年5月4日 GMT+2 下午3:02:46 - permalink - archive.org - https://github.com/Cue/scales
    metric python
  • thumbnail
    unix - How can I pretty-print JSON? - Stack Overflow

    How to pretty print a json string :

    cat pref.json | python -m json.tool

    for uuoc nazi ;) :

    < pref.json python -m json.tool
    or
    python -m json.tool < pref.json

    2014年9月3日 GMT+2 上午10:33:46 - permalink - archive.org - http://stackoverflow.com/questions/352098/how-can-i-pretty-print-json
    commandline json linux pretty print python
  • What happens if you write a TCP stack in Python? - Julia Evans

    Pour le fun et le learning : faire du tcp avec python / scapy

    via sametmax

    2014年8月12日 GMT+2 下午9:18:00 - permalink - archive.org - http://jvns.ca/blog/2014/08/12/what-happens-if-you-write-a-tcp-stack-in-python/
    networking python scapy
  • Welcome to web.py! (web.py)

    mini web framework en python, dans le meme genre que bottle :
    http://bottlepy.org/docs/dev/index.html

    2014年7月7日 GMT+2 上午10:56:12 - permalink - archive.org - http://webpy.org/
    framework python web
Links per page: 20 50 100
◄Older
page 4 / 5
Newer►
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Help/documentation