4337 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()

    November 17, 2017 at 9:37:26 AM GMT+1 - 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 ^^

    November 17, 2017 at 9:34:14 AM GMT+1 - 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)

    July 11, 2017 at 10:05:21 AM GMT+2 * - 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'
    June 15, 2017 at 11:12:05 AM GMT+2 * - 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))

    May 29, 2017 at 2:15:06 PM GMT+2 - 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!

    May 4, 2017 at 2:11:45 PM GMT+2 - 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
           
    April 21, 2017 at 4:19:03 PM GMT+2 * - 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

    March 24, 2017 at 4:02:34 PM GMT+1 - 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.

    March 2, 2017 at 9:09:38 PM GMT+1 - 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:")

    March 2, 2017 at 8:56:16 PM GMT+1 - 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
    September 29, 2016 at 11:16:39 AM GMT+2 - 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

    August 16, 2016 at 5:40:40 PM GMT+2 - 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

    February 23, 2016 at 9:57:51 AM GMT+1 - 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
    February 18, 2016 at 10:55:56 AM GMT+1 - 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

    January 1, 2016 at 10:21:09 AM GMT+1 - 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/
    November 9, 2015 at 2:55:05 PM GMT+1 - 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)

    May 4, 2015 at 3:02:46 PM GMT+2 - 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

    September 3, 2014 at 10:33:46 AM GMT+2 - 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

    August 12, 2014 at 9:18:00 PM GMT+2 - 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

    July 7, 2014 at 10:56:12 AM GMT+2 - 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