This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python2 | |
| import os | |
| from glob import glob | |
| from datetime import datetime, timedelta | |
| root_dir = '/var/local/crm/data/launches/' | |
| def print_oldfiles(root_dir, olddays=20, minsizemb=10): | |
| sizesmb = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import multiprocessing as mp | |
| import logging | |
| def get_mp_logger(): | |
| logger = mp.get_logger() | |
| logger.handlers = [logging.FileHandler('/tmp/pool.log', mode='a'), logging.StreamHandler()] | |
| logger.setLevel(logging.INFO) | |
| formatter = logging.Formatter('%(asctime)s %(message)s') | |
| logger.handlers[0].setFormatter(f) | |
| logger.handlers[1].setFormatter(f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from tornado.wsgi import WSGIContainer | |
| from tornado.httpserver import HTTPServer | |
| from tornado.ioloop import IOLoop | |
| app = Flask(....) | |
| http_server = HTTPServer(WSGIContainer(app)) | |
| http_server.listen(self.settings.web_port) | |
| IOLoop.instance().start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tar -czf - ./dir | (pv -p --timer --rate --bytes > backup/$(date +"%Y.%d.%m-%H.%M").tgz) | |
| A quick way of backing up a list of programs is to run this: | |
| dpkg --get-selections > ~/Package.list | |
| sudo cp -R /etc/apt/sources.list* ~/ | |
| sudo apt-key exportall > ~/Repo.keys | |
| It will back them up in a format that dpkg can read* for after your reinstall, like this: | |
| sudo apt-key add ~/Repo.keys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import pprint | |
| class Stored: | |
| def __init__(self, init_dict=None): | |
| if init_dict: | |
| self.__dict__ = init_dict | |
| def save(self, file_name): | |
| with open(file_name, 'w') as fd: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import logging.handlers | |
| import os.path as path | |
| def configure_logger( | |
| logger_name='logger', | |
| log_dir='/tmp/', | |
| filename='', | |
| to_stdout=True, |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.