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
| settings = {} | |
| @celery.task | |
| def upload_attachment_to_s3(msg_id, file_data): | |
| conn = boto.connect_s3(settings['aws_access_key_id'], settings['aws_secret_access_key']) | |
| #Connect to bucket and create key | |
| bucket_url = settings['env'] + '.attachments' | |
| b = conn.get_bucket(bucket_url) | |
| key_url = str(msg_id) + file_data['filename'] |
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
| Note return type on end of function: | |
| func add(x int, y int) int { | |
| return x + y | |
| } | |
| Can be shortened to: | |
| func add(x, y int) int { | |
| return x + y | |
| } |
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
| # use with: logging.config.dictConfig(yaml.load(open('logging.yaml', 'r'))) | |
| # Formatters detailed here: http://docs.python.org/2/library/logging.html#logrecord-attributes | |
| version: 1 | |
| formatters: | |
| simple: | |
| format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
| detail: | |
| format: '%(asctime)s - %(levelname)s - File: %(filename)s - %(funcName)s() - Line: %(lineno)d - %(message)s' |
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 | |
| # set up logging to file - see previous section for more details | |
| logging.basicConfig(level=logging.DEBUG, | |
| format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', | |
| datefmt='%m-%d %H:%M', | |
| filename='myapp.log', | |
| filemode='w') |
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
| # -------- models -------------- | |
| class CheckStart(models.Model): | |
| check_start = models.OneToOneField(Checklist, related_name="start") | |
| Registration = models.BooleanField(default=False) | |
| Make_an_offer = models.BooleanField(default=False) | |
| Offer_accepted = models.BooleanField(default=False) | |
| class CheckStartForm(ModelForm): |
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 imaplib | |
| import email | |
| from pprint import pprint | |
| import re | |
| import collections | |
| from email.Iterators import typed_subpart_iterator | |
| """ Assumes you have TFL email you each time your oyster auto top up occurs """ | |
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
| class TestEmailer(unittest.TestCase): | |
| def setUp(self): | |
| super(TestEmailer, self).setUp() | |
| self.applied_tasks = [] | |
| self.original_celery = celery_jobs.post_url.delay | |
| def new_apply_async(*args): | |
| self.applied_tasks.append(args) |
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 import httpclient | |
| from tornado import auth | |
| from tornado import httputil | |
| from tornado import escape | |
| import urllib | |
| #from tornado.httputil import url_concat | |
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
| {{locale.format_date(c['_id'].generation_time.replace(tzinfo=None))}} |