This was tested on:
- Ubuntu 14.04 x64
- Ubuntu 16.04 x64
# -*- coding: utf-8 -*- | |
"""Example Google style docstrings. | |
This module demonstrates documentation as specified by the `Google Python | |
Style Guide`_. Docstrings may extend over multiple lines. Sections are created | |
with a section header and a colon followed by a block of indented text. | |
Example: | |
Examples can be given using either the ``Example`` or ``Examples`` | |
sections. Sections support any reStructuredText formatting, including |
from re import match | |
from urllib.parse import urlparse | |
from urllib.parse import ParseResult | |
def get_parsed_url(url): | |
p = urlparse(url, 'http') | |
netloc = p.netloc or p.path | |
path = p.path if p.netloc else '' | |
if not netloc.startswith('www.'): | |
netloc = 'www.' + netloc |
# Built-in imports. | |
from sys import argv | |
from os.path import join as join_path | |
# Third party imports. | |
from pandas import read_csv | |
def get_row_count(src_filepath): | |
with open(src_filepath, 'r') as f: |
import sys, os, django | |
sys.path.append("/path/to/store") #here store is root folder(means parent). | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "store.settings") | |
django.setup() | |
from store_app.models import MyModel |
# from: https://github.com/dpkp/kafka-python/blob/master/example.py | |
import threading, logging, time | |
import multiprocessing | |
from kafka import KafkaConsumer, KafkaProducer | |
class Producer(threading.Thread): | |
def __init__(self): |
#!/usr/bin/env bash | |
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/ | |
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c | |
# https://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver | |
# https://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception | |
# https://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal | |
# https://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04 | |
# Versions | |
CHROME_DRIVER_VERSION=`curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE` |
import logging | |
import time | |
from celery import shared_task as orig_shared_task | |
def timeit(func): | |
"""A decorator used to log the function execution time.""" | |
logger = logging.getLogger('tasks') |
/* Useful celery config. | |
app = Celery('tasks', | |
broker='redis://localhost:6379', | |
backend='redis://localhost:6379') | |
app.conf.update( | |
CELERY_TASK_RESULT_EXPIRES=3600, | |
CELERY_QUEUES=( | |
Queue('default', routing_key='tasks.#'), |
from django.conf import settings | |
class DatabaseAppsRouter(object): | |
""" | |
A router to control all database operations on models for different | |
databases. | |
In case an app is not set in settings.DATABASE_APPS_MAPPING, the router | |
will fallback to the `default` database. | |