4337 links
  • Arnaud's links
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
    Type 1 or more characters for results.
    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()

      17 novembre 2017 à 09:37:26 UTC+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 ^^

      17 novembre 2017 à 09:34:14 UTC+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)

      11 juillet 2017 à 10:05:21 UTC+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'
      15 juin 2017 à 11:12:05 UTC+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))

      29 mai 2017 à 14:15:06 UTC+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!

      4 mai 2017 à 14:11:45 UTC+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
             
      21 avril 2017 à 16:19:03 UTC+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

      24 mars 2017 à 16:02:34 UTC+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.

      2 mars 2017 à 21:09:38 UTC+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:")

      2 mars 2017 à 20:56:16 UTC+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
      29 septembre 2016 à 11:16:39 UTC+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

      16 août 2016 à 17:40:40 UTC+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

      23 février 2016 à 09:57:51 UTC+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
      18 février 2016 à 10:55:56 UTC+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

      1 janvier 2016 à 10:21:09 UTC+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/
      9 novembre 2015 à 14:55:05 UTC+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)

      4 mai 2015 à 15:02:46 UTC+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

      3 septembre 2014 à 10:33:46 UTC+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

      12 août 2014 à 21:18:00 UTC+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

      7 juillet 2014 à 10:56:12 UTC+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