Skip to content

Instantly share code, notes, and snippets.

View AlexandreProenca's full-sized avatar
:octocat:
Focusing

Alexandre Proença AlexandreProenca

:octocat:
Focusing
View GitHub Profile
from pymongo import MongoClient
client = MongoClient()
db = client.sbhistory
cursor = db.room.find()
for document in cursor:
document['payload']['details']['users_name'] = [{"username": i, "seen": None, "received": None} for i in document['payload']['details']['users_name']]
db.room2.insert(document)
#!/usr/bin/env python
import sys, os, time, atexit
from signal import SIGTERM
import logging
import logging.handlers
my_logger = logging.getLogger('LoyfyLogger')
my_logger.setLevel(logging.CRITICAL)
with open(args.project_name + r'/settings.py', 'wt') as fout:
with open(resource_filename('robot_rest', 'settings.tpl'), 'rt') as fin:
for line in fin:
if '@projeto@' in line:
fout.write(line.replace('@projeto@', args.project_name))
elif '@HOST@' in line:
fout.write(line.replace('@HOST@', args.database_host))
elif '@USER@' in line:
fout.write(line.replace('@USER@', args.database_user))
elif '@PASSWORD@' in line:
  • Update HISTORY.rst
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Install the package again for local development, but with the new version number:
python setup.py develop
  • Run the tests:
python setup.py test
@AlexandreProenca
AlexandreProenca / formater.py
Created August 23, 2015 15:20
Classe para formatar a saída dos resultados de performance do Django + DRF 3
# coding: utf-8
class Formater:
cor = {
'ROXO' : '\033[95m',
'AZUL' : '\033[94m',
'VERDE' : '\033[92m',
'AMARELO' : '\033[93m',
'VERMELHO' : '\033[91m',
@AlexandreProenca
AlexandreProenca / view.py
Created August 23, 2015 15:16
Classe para teste de performance Django + DRF 3
# coding: utf-8
from rest_framework import viewsets
from rest_framework.response import Response
from rest_framework.authentication import TokenAuthentication, SessionAuthentication
from rest_framework.permissions import AllowAny, IsAuthenticated
import models
from rest_framework.decorators import detail_route, list_route, api_view, authentication_classes
import serializers
from django.core.signals import request_finished, request_started
import time