Create a new tmux session:
tmux new-session -s my-session # launch `top`, `htop`, or anything that will regularly updates, then detach
Stream your session:
with open('/path/file.csv', 'w') as f: | |
writer = csv.writer(f) | |
for i in range(100000): | |
writer.writerow([i]) |
@deconstructible | |
class VersioningFileSystemStorage(FileSystemStorage): | |
""" The modified version of the original :class:`FileSystemStorage` will | |
append a hash to any file being saved regardless of whether the original | |
file name is already taken or not so any file saved will have it. | |
The backend is meant to be used with model versioning to provide simple | |
file versioning as well. | |
A security consideration of the approach is that though there is a hash, | |
which cannot be guessed manually, the ``MEDIA_ROOT`` directory is usually | |
world-readable. So potentially, an automatic guessing could reveal |
class M2MNestedSerializerMixin(object): | |
""" | |
Nested serializer mixin for M2M fields. | |
You need mix serializer mixin to you serializer and append M2M fields to | |
Meta.m2m_nested_fields. | |
""" | |
m2m_nested_objects = {} | |
class Meta: |
class BaseTranslationMixin(object): | |
def __init__(self, instance=None, data=empty, **kwargs): | |
if not self.Meta.model_translation: | |
raise AttributeError( | |
'You must define Meta.model_translation attribute') | |
super().__init__(instance=instance, data=data, **kwargs) | |
@staticmethod | |
def get_translation_fields(languages, fields): |
class ForeignKeySerializerMixin(object): | |
""" | |
Mixin for processing foreign key field serializers | |
""" | |
class Meta: | |
foreign_key_fields = () | |
def is_valid(self, raise_exception=False): | |
# TODO: костыль, после выхода 3.4.8 посмотреть решён ли баг | |
# DRF parent-level validation of nested serializer bug |
class BulkViewSetMixin(object): | |
""" | |
Mixin for bulk create and update operations. | |
You need used Bulk routers for providing routing to bulk operations, | |
for example BulkNestedSimpleRouter. | |
""" | |
def create(self, request, *args, **kwargs): | |
bulk = isinstance(request.data, list) | |
if not bulk: |
# -*- coding: utf-8 -*- | |
""" | |
Selenium loading module | |
""" | |
import os | |
import time | |
import psutil | |
import logging | |
from django.conf import settings |
""" | |
Django signals example | |
""" | |
import logging | |
from django.dispatch import receiver | |
from django.dispatch import Signal | |
from django.db.models.signals import pre_save | |
from statistics.models import Client, Dealer |
""" | |
Using lxml for a web pages scrapping | |
""" | |
def process_goods_page(self, document, url): | |
""" Scrapping of goods on the html page """ | |
items = [] | |
if settings.DEBUG: | |
try: |