Saravanan666/pypi-org huggingface dataset:
Package: django-run-queues
Django Run Queues allows you to queue specific tasks, within a set of queues of your choice. Tasks are then run via scheduled commands using CRON and are run in sequence.Thus you can queue tasks in multiple queues and then use Cron to decide when tasks in each queue will be processed.Also Tasks for a given queue are run in sequence. If another command starts to process a queue already running, then it will not proceed and stop. Thus for example if you are working in a load balanced environment and have issues because the command will start on multiple servers, this is not a problem. One will process and the others will silently fall over.DRQ also comes with a simple system based upon python-crontab, to create the cron records from your settings and a django command
Package: django_runtests
Eases the writing of aruntests.pyscript for pluggable django application.Such scripts usually provide aruntests()method that handle the test running behaviour.InstallationGlobally:$ pip install django-runtestsFrom the package’ssetup.pyfile (using Distribute):setup(
    test_requires=[
        'django-runtests',
    ],
    test_suite='runtests.runtests',
)Defining the test setupIn yourruntests.pyfile, add the following code:from django_runtests import RunTests

def runtests():
    return RunTests.runtests()

if __name__ == '__main__':
    RunTests.main()Tweaking the test setupIf you need to tweak some parts (updating configuration, adding options, …), you
simply have to extend theRunTestscommand class:import django_runtests

class RunTests(django_runtests.RunTests):

    def should_test_app(self, app):
        """Test only applications listed in 'PACKAGE_APPS' setting."""
        from django.conf import settings
        return app in settings.PACKAGE_APPS
Package: django-runtime-options
Django Runtime OptionsRequirementsPython 3.6+Django 2.2+InstallationInstall with pippip install django-runtime-optionsAddoptionstoINSTALLED_APPSINSTALLED_APPS=(...'options.apps.OptionsConfig',...)(Optionally) add the following tourls.pyurlpatterns=[...path("options/",include("options.urls",namespace="options")),...]DocumentationRuntime options can either be set in the django admin site or by using thesetoptioncommand.An example of the management command is./manage.py setoption key value --type TXTwhich will create or update an option with the key "key" to the value "value"ChangelogSeeCHANGELOG.mdLicenseSeeLICENSE
Package: django-russian_fields
=====Django Russian Fields=====Приложение содержит поля, специфичные для разработки в российских условиях.Список полей::* INNField* KPPField* OGRNField* PhoneNumberFieldИнструкция-----------1. Установите пакет с помощью pip::pip install django-russian_fields2. Добавьте "russian_fields" в INSTALLED_APPS::INSTALLED_APPS = (...'russian_fields',)3. Импортируйте нужное поле в ваш models.py::from russian_fields.models.fields import INNField4. Используйте импортированное поле в вашей модели::class MyModel(models.Model):...inn = INNField(verbose_name=u"ИНН")5. Радуйтесь!
Package: django-ru-validators
Django russian financial validatorsl10n russian validators for INN, bank account numberInstall$pipinstalldjango-ru-validatorsUsagefromdjangoimportformsfromdjango.dbimportmodelsfromdjango.core.exceptionsimportValidationErrorfromdjango_ru_validatorsimportvalidate_inn,BankAccountNumberValidatorclassPaymentOrder(models.Model):recipient_inn=models.CharField(validators=[validate_inn])recipient_account_number=models.CharField()recipient_bank=models.CharField()classPaymentOrderForm(forms.ModelForm):classMeta:model=PaymentOrderfields=("recipient_inn","recipient_account_number","recipient_bik")defclean(self):cleaned_data=super().clean()recipient_account_number=cleaned_data.get("recipient_account_number")recipient_bik=cleaned_data.get("recipient_bik")try:BankAccountNumberValidator(recipient_bik)(recipient_account_number)exceptValidationError:msg="Wrong combination of account number and bik of bank"self.add_error("recipient_account_number",msg)self.add_error("recipient_bik",msg)returncleaned_dataDevelopmentInstall dependencies with$pipinstall--requirementrequirements.txtRun tests with$pythonsetup.pytest
Package: django-s3-collectstatic
# django-s3-collectstaticThis package includes a management command `fasts3collectstatic` that isintended for use with the S3BotoStorage storage backend. When checking if afile already exists it uses the S3 etag for comparison instead of the defaultmodified time. This is especially useful when deploying to Heroku, since Herokuchanges the modified time when deploying.The code is based on [this Django snippet](http://djangosnippets.org/snippets/2889/)with some fixes and packaging.## InstallationClone the [Git repository](https://github.com/agoodid/django-s3-collectstatic)or use pip to install:pip install git+git://github.com/AGoodId/django-s3-collectstatic.git#egg=django-s3-collectstaticIn `settings.py`:STATICFILES_STORAGE ="storages.backends.s3boto.S3BotoStorage"AWS_PRELOAD_METADATA = TrueINSTALLED_APPS = [# ...'django_s3_collectstatic',]
Package: django-s3-csv-2-sfdc
OverviewA set of helper functions for CSV to Salesforce procedures, with reporting in AWS S3, based in a Django project.
The use case is extremely specific, but the helpers should be modular so they can be cherry-picked.Typical use case:Receive an S3 eventDownload the S3 objectSerialize the file into JSONBulk upsert the JSON data to SalesforceParse the results of the upsert for errorsConstruct a CSV error reportMove the triggering S3 object to an archive folderPush the error report to an error folder in the same bucketPush an object to Salesforce that details information about the above executionHigh-level ExampleUsing theOrchestratorclass, you can skip manually setting up a lot of the above
steps. This class is intended to be subclassed, and should provide plenty of options
for overriding methods to better suit your use-case.Inheriting the Orchestrator# orchestrator.pyfromdjango.confimportsettingsfromdjango_s3_csv_2_sfdc.classesimportOrchestratorasBaseOrchestratorclassOrchestrator(BaseOrchestrator):def__init__(self,*args,**kwargs)->None:super().__init__(*args,**kwargs)# This must be defined in the child class because your Salesforce object could be named anythingself.execution_object_name="Integration_Execution__c"@propertydefexecution_sfdc_hash(self):# And it could have any number of fieldsreturn{"Number_of_Errors__c":self.error_count,"Error_Report__c":self.error_report_link,"Data_File__c":self.s3_object_key,}@propertydeferror_report_link(self):returnf"https://{self.bucket_name}.{settings.AWS_REGION}.amazonaws.com/{self.error_file_s3_key}"Using the Orchestrator# biz_logic.pyfromdjango.confimportsettingsfromdjango_s3_csv_2_sfdc.classesimportSfClient# import the custom Orchestrator defined abovefrom.orchestratorimportOrchestratorsalesforce=SfClient()orchestrator=Orchestrator("some/s3/key/file.csv",settings.S3_BUCKET,sf_client=salesforce)upsert_key="My_External_ID__c"accounts_data=[{"Name":"A name",upsert_key:"123"}]results=salesforce.bulk.Account.upsert(results,upsert_key)# You'll call log_batch for each batch you upload. This method# will parse the results in search of errorsorchestrator.log_batch(results,accounts_data,"Account",upsert_key)# This will create the error report, archive the source s3 file, and push# the integration object to Salesforce. You'll definitely want to customize# this by overriding this method or the methods it invokesorchestrator.automagically_finish_up()Low-level Examplefromdjango_s3_csv_2_sfdc.csv_helpersimportcreate_error_reportfromdjango_s3_csv_2_sfdc.s3_helpersimportdownload_file,respond_to_s3_event,upload_filefromdjango_s3_csv_2_sfdc.sfdc_helpersimportextract_errors_from_results# handler for listening to s3 eventsdefhandler(event,context):respond_to_s3_event(event,download_and_process)defdownload_and_process(s3_object_key,bucket_name):download_path=download_file(s3_object_key,bucket_name)# This function contains your own biz logic; does not come from this libraryresults=serialize_and_push_to_sfdc(download_path)sucesses,errors=parse_bulk_upsert_results(results)report_path,errors_count=create_error_report([errors])upload_file(report_path,bucket_name)Just take what'cha need!
Package: django-s3-file-field-client
django-s3-file-field-clientA Python client library for django-s3-file-field.Installationpipinstalldjango-s3-file-field-clientUsageimportmimetypesimportpathlibimportrequestsfroms3_file_field_clientimportS3FileFieldClientapi_client=requests.Session()# This can be used to set authentication headers, etc.s3ff_client=S3FileFieldClient('http://localhost:8000/api/v1/s3-upload/',# The path mounted in urlpatternsapi_client,# This argument is optional)file_to_upload=pathlib.Path('/path/to/my_file.txt')withfile_to_upload.open('rb')asfile_stream:# Open in binary modefield_value=s3ff_client.upload_file(file_stream=file_stream,# This can be any file-like objectfile_name=file_to_upload.name,file_content_type=mimetypes.guess_type(file_to_upload)[0],field_id='core.File.blob',# The "<app>.<model>.<field>" to upload to)api_client.post('http://localhost:8000/api/v1/file/',# This is particular to the applicationjson={'blob':field_value,# This should match the field uploaded to (e.g. 'core.File.blob')...:...,# Other fields for the POST request})
Package: django-s3-folder-storage
# django-s3-folder-storage[![Build Status](https://travis-ci.org/jamstooks/django-s3-folder-storage.svg)](https://travis-ci.org/jamstooks/django-s3-folder-storage)[![Code Climate](https://codeclimate.com/github/jamstooks/django-s3-folder-storage/badges/gpa.svg)](https://codeclimate.com/github/jamstooks/django-s3-folder-storage)Quick extension of django-storages' [S3BotoStorage](http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html) to allow separate folders for uploaded and static media within an S3 bucket.## OverviewMany of my sites use the same configuration: **static** files are stored in `//s3.amazonaws.com/<bucket_name>/static/` and **uploaded** files are stored somewhere under `//s3.amazonaws.com/<bucket_name>/media/`. Instead of extending S3BotoStorage in every project I decided to build a package. The names of those folders are configurable in `settings.py`.## InstallationUse `pip` to install from PyPI:pip install django-s3-folder-storageAdd `s3_folder_storage` to your settings.py file:INSTALLED_APPS = (...'s3_folder_storage',...)## ConfigurationYou are essentially using `django-storages` for S3 hosting, so you will be using their settings. The two settings that are specific to `django-s3-folder-storage` are `DEFAULT_S3_PATH` and `STATIC_S3_PATH`.Here's an example:DEFAULT_FILE_STORAGE = 's3_folder_storage.s3.DefaultStorage'DEFAULT_S3_PATH = "media"STATICFILES_STORAGE = 's3_folder_storage.s3.StaticStorage'STATIC_S3_PATH = "static"AWS_ACCESS_KEY_ID = {{ your key id here }}AWS_SECRET_ACCESS_KEY = {{ your secret key here }}AWS_STORAGE_BUCKET_NAME = {{ your bucket name here }}MEDIA_ROOT = '/%s/' % DEFAULT_S3_PATHMEDIA_URL = '//s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAMESTATIC_ROOT = "/%s/" % STATIC_S3_PATHSTATIC_URL = '//s3.amazonaws.com/%s/static/' % AWS_STORAGE_BUCKET_NAMEADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'## TroubleshootingDepending on how you have your buckets configured and if you want to use SSL,you may need to use something like the following:MEDIA_URL = 'https://%s.s3.amazonaws.com/media/' % AWS_STORAGE_BUCKET_NAMESTATIC_URL = 'https://%s.s3.amazonaws.com/static/' % AWS_STORAGE_BUCKET_NAMEAs a first step, I recommend trying to get the `collectstatic` managementcommand working within your project:python manage.py collectstaticYou can also run the tests:python manage.py test s3_folder_storageto confirm that files are being written to S3## ContributingThink this needs something else? To contribute to `django-s3-folder-storage` create a fork on github. Clone your fork, make some changes, and submit a pull request.Bugs are great contributions too! Feel free to add an issue on github.
Package: django-s3sign
django-s3signs3 sign view for djangoinstallation$ pip install django-s3signusageAdds3signtoINSTALLED_APPS. Subclasss3sign.views.SignS3Viewand override as needed.Attributes you can override (and their default values):name_field = 's3_object_name'
    type_field = 's3_object_type'
    expiration_time = 10
    mime_type_extensions = [
        ('bmp', '.bmp'),
        ('gif', '.gif'),
        ('jpeg', '.jpg'),
        ('pdf', '.pdf'),
        ('png', '.png'),
        ('svg', '.svg'),
        ('webp', '.webp'),
    ]
    default_extension = '.obj'
    root = ''
    path_string = (
        "{root}{now.year:04d}/{now.month:02d}/"
        "{now.day:02d}/{basename}{extension}")
    acl = "public-read"Methods you can override:get_aws_access_key(self)get_aws_secret_key(self)get_bucket(self)get_mimetype(self, request)extension_from_mimetype(self, mime_type)now(self)# useful for unit testsnow_time(self)# useful for unit testsbasename(self)get_object_name(self, extension)Most of those should be clear. Read the source if in doubt.Eg to use a different root path:from s3sign.views import SignS3View
...

class MySignS3View(LoggedInView, SignS3View):
    root = 'uploads/'With a different S3 bucket:class MySignS3View(LoggedInView, SignS3View):
    def get_bucket(self):
        return settings.DIFFERENT_BUCKET_NAMEKeeping the uploaded filename instead of doing a random one and
whitelisted extension:class MySignS3View(LoggedInView, SignS3View):
    def basename(self, request):
        filename = request.GET[self.get_name_field()]
        return os.path.basename(filename)

    def extension(self, request):
        filename = request.GET[self.get_name_field()]
        return os.path.splitext(filename)[1]javascript/formsThe required javascript is also included, so you can include it in
your page with:{% load static %}

<script src="{% static 's3sign/js/s3upload.js' %}"></script>Your form would then somewhere have a bit like:<form method="post">
    <p id="status">
        <strong>Please select a file</strong>
    </p>

    <input type="hidden" name="s3_url" id="uploaded-url" />
    <input type="file" id="file" onchange="s3_upload();"/>
</form>And<script>
function s3_upload() {
    var s3upload = new S3Upload({
        file_dom_el: null, // Optional, and overrides file_dom_selector
                           // when present.
        file_dom_selector: '#file',
        s3_sign_put_url: '/sign_s3/', // change this if you route differently
        s3_object_name: $('#file')[0].value,

        onProgress: function(percent, message) {
            $('#status').text('Upload progress: ' + percent + '% ' + message);
        },
        onFinishS3Put: function(url) {
            $('#uploaded-url').val(url);
        },
        onError: function(status) {
            $('#status').text('Upload error: ' + status);
        }
    });
}
</script>
Package: django-s3-static
Installation$[sudo]pipinstalldjango-s3-staticsettings.pyINSTALLED_APPS=["django_s3_static",]settings/dev.pySTATIC_ROOT=os.path.join(BASE_DIR,'static')STATIC_URL='/static/'settings/prod.pyAWS_STATIC_ACCESS_KEY_ID=os.getenv('AWS_STATIC_ACCESS_KEY_ID')AWS_STATIC_SECRET_ACCESS_KEY=os.getenv('AWS_STATIC_SECRET_ACCESS_KEY')AWS_STATIC_BUCKET=os.getenv('AWS_STATIC_BUCKET')STATIC_ROOT=os.path.join(BASE_DIR,'static')STATIC_URL="https://%s.s3.amazonaws.com/"%AWS_STATIC_BUCKETExamples$pythonmanage.pys3_static_create# create s3 bucket and policy$pythonmanage.pys3_static_sync# sync static folder with s3 bucket{% load static %}<linkrel="stylesheet"href="{% static "css/file.css"%}">readme42.com
Package: django-s3-storages-utils
A simple app that allows a bit more control over the S3BotoStorage provided by
django-storagesIt’s use is fairly simple. Just put this in your settings:# Store the static files in the directory `static` in the S3 bucket
STATIC_S3_STORAGE_LOCATION = 'static'

# Store the media files in the directory `media` in the S3 bucket
MEDIA_S3_STORAGE_LOCATION = 'media'

DEFAULT_FILE_STORAGE = 's3storagesutils.MediaCachedS3BotoStorage'
STATICFILES_STORAGE = 's3storagesutils.StaticCachedS3BotoStorage'

# If you're using compressor
COMPRESS_STORAGE = STATICFILES_STORAGEThat’s all for now!
Package: django-sa
=============================django-sa=============================Utility to convert a python script into a standalone django script.For Python2/Python3 and Django 1.7+Installation----------Install::pip install django-saImplementation Notes with Short Examples----------What happens when you try to run a script with django code in it?::python backup.py.. code-block:: pythonTraceback (most recent call last):File "backup.py", line 6, in <module>↓↓↓django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.django-sa way::+ The script needs to be run from the project root directory+ This uses the default django settings file which is in project_dir/settings.py.. code-block:: pythonfrom django_sa import setup_djangosetup_django(__file__)from community.models import Botbot = Bot.objects.get(pk=101)bot.backup(async=True)Using a different django settings file:.. code-block:: pythonfrom django_sa import setup_djangosetup_django(__file__, 'my_project.settings.production')from community.models import Botbot = Bot.objects.get(pk=101)bot.backup(async=True)* Version 0.1.0.1 (2017-09-23)++++++++++++++++++* First release on PyPI.
Package: django-saas-email
An email manager for sending emails with templates, mail history and admin.FeaturesUse ofMailhogfor local email testing.Send emails viadjango-anymail(usingSendgridas default).Serving dynamic HTML E-Mail Templates, editable withTinymce.Use of the awesomeTransactional email templatesfromMailgun.DocumentationThe full documentation is athttps://django-saas-email.readthedocs.io.QuickstartInstallationInstallation with pip:pip install django-saas-emailAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'django_saas_email.apps.DjangoSaasEmailConfig',...)Add a template engineTEMPLATES:TEMPLATES=[...{"BACKEND":"django.template.backends.django.DjangoTemplates","APP_DIRS":True,"DIRS":["django_saas_email/templates/"],"NAME":"email","OPTIONS":{"string_if_invalid":"{%s}"},}]JSONFieldWe are using the Postgres JSONField as default. If you installedpsycopg2, everything should work fine.If you are using a different database, you also need to installjsonfield:pip install jsonfieldAdding the Sendgrid API Key to your settingsIn settings.py:SENDGRID_API_KEY=<....>Other optional settings:DJANGO_SAAS_TEST_EMAIL_ADDRESS=youremailfortesting@example.org
DJANGO_SAAS_FOOTER="""Follow <a href="#" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 12px; color: #999; text-decoration: underline; margin: 0;">@yourcompany</a> on Twitter"""Sending emailsfromdjango_saas_email.utilsimportcreate_and_send_mailcontext={'first_name':'John','last_name':'Doe',}create_and_send_mail(template_name="hello_world",context=context,to_address="john.doe@example.org")This will create an email and send it with Sengrid.You should usehttp://premailer.dialect.caor django-premailer to create Inline CSS in HTMLBackground sendingThis module sends emails asynchronously. To do that, it usescelery.
You will need to run and configureceleryto really send emails using the
library.The best source to do that isFirst Steps with Celery.But you may use the following simple guide if you want to make it fast:Create acelery.pyfile aside yourwsgi.pyfile with the following content:from__future__importabsolute_import,unicode_literalsimportosfromceleryimportCeleryos.environ.setdefault('DJANGO_SETTINGS_MODULE','config.settings')app=Celery(<YOUR_APP_NAME>)app.config_from_object('django.conf:settings',namespace='CELERY')app.autodiscover_tasks()Change<YOUR_APP_NAME>to the name of your app.InstallRabbitMQ.Runcelery:celery-A<YOUR_APP_NAME>worker-B-ldebugChange<YOUR_APP_NAME>to the name of your app.Now you might just send the email with no problem usingcreate_and_send_mailfunction.Running TestsDoes the code actually work?:source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ toxHistory0.1.0 (2017-07-24)First release on PyPI.
Package: django-sabot
Sabot: Controlled failure for DjangoDescriptionProvoke predictable errors in your Django projects. Raise OperationalErrors to
see how well your project handle database connection errors. Ideal for failure
tolerance testing.LicenseThis project is open sourced under theMIT License.Installation$pipinstalldjango-sabotAdd'sabot', to your project’sINSTALLED_APPSlist.Add some sabot patches in your settings.py file.UsageIn you settings.py file:from django.db import OperationalError

from sabot.import *

SABOT_PATCHES = (
    ConnectPatcher(error_generator=RandomErrorProducer, kwargs={'low': 1, 'high': 3}),
    CursorPatcher(error_producer=RandomErrorProducer, kwargs={'exception': OperationalError, 'low': 1, 'high': 10}),
    CursorPatcher(error_producer=CountErrorProducer, kwargs={'exception': OperationalError, 'number': 100, 'reset': True}),
    CursorPatcher(error_producer=TimeDeltaErrorProducer, kwargs={'exception': OperationalError, 'timedelta': {'seconds': 30}, 'reset': True}),
)A django-sabot patch is composed of a monkey patcher class and an error producer
class.For example:CursorPatcher(error_producer=TimeDeltaErrorProducer, kwargs={'exception': OperationalError, 'timedelta': {'seconds': 30}, 'reset': True}),will produce an OperationalError when a database cursor is requested, every 30
seconds.ContributeCheck for open issues or open a fresh issue to start a discussion around a feature idea or a bug.Forkthe repositoryon GitHub to start making your changes to themasterbranch (or branch off of it).Write a test which shows that the bug was fixed or that the feature works as expected.Make sure to add yourself to theAUTHORS file.Send a pull request0.1.0 (2015-07-20)Initial release