Library of helpers for python development.
pip install developers-chamber
Docker and docker-compose is required for most of pydev project
commands.
If you want to use pydev command pydev project bind-library
you have to install bindfs
for mounting location to the right directory. For exymple you can mount directory with library to a docker shared volume.
Instalation command for linux/macOS:
apt-get install bindfs
yum install bindfs
brew install bindfs
You can install a bash completion with pydev command init-completion
:
pydev init-completion
You can configure pydev for your project with config files. You can define more config files which is loaded with alphabetical order (file with the highest order will override the same configuration with the lowest order).
There are two places for the pydev configuration files. One place is used for all the projects and the second one is project specific.
The purpose of the general pydev settings is to have some place where you can store your personal or secret configuration for example key to your personal toggle account. The directory for general settings is $HOME/.pydev
.
The project configuration directory is stored in path $PROJECT_DIR/.pydev
and works only if pydev commands are run in the $PROJECT_DIR
directory. The same values in the general configuration will be overriden by to project configuration.
Configuration files which are stored in the .pydev
directory must have this format:
./.pydev/
base.conf
dev.conf
prod.conf
If you want to disable configuration file you can rename it to start with character ~
. In the example ~prod.conf
will be ignored:
./.pydev/
base.conf
dev.conf
~prod.conf
The configuration file may contain project settings and aliases.
Project settings saves the time to the developers because pydev input parameters may be omitted if the parameter is defined in the configuration file. Example of such file can be:
JIRA_PROJECT_KEY=PROJ PROJECT_DOCKER_COMPOSE_FILES=path/to/the/compose.yaml PROJECT_DOCKER_COMPOSE_DEFAULT_UP_CONTAINERS=container_a,container_b PROJECT_DOCKER_COMPOSE_CONTAINERS_DIR_TO_COPY=container_a:/usr/local/lib/python3.11/site-packages:var/site-packages PROJECT_DOCKER_COMPOSE_CONTAINERS_INSTALL_COMMAND=base:./manage.py compilemessages && ./manage.py migrate && ./manage.py collectstatic PROJECT_DOCKER_COMPOSE_VAR_DIRS=var,var/data/media,var/data/static PROJECT_LIBRARY_DIR=var/site-packages
Alias is a shortcut for the developer to save his time and are defined with ALIASES
setting in a JSON format:
ALIASES='{
"up": "project up",
"up-all": "project up -a",
}'
You can now use aliases to run pydev commands:
pydev up # instead of pydev project up
pydev up-all # instead of pydev project up -a
You can write alias with arguments too:
ALIASES='{
"migrate": "project run \"python manage.py migrate $app\"",
}'
You can now run migration to the concrete app with:
pydev migrate --app=users # it will run pydev project run "python manage.py migrate users"
There can be situations when you need to alias on more commands. You can use JSON list to specify it:
ALIASES='{
"build-js": ["project run -c static \"build-js.sh\"", "project run -c base \"./manage.py collectstatic\""],
}'
Now you can run only one pydev command to build js and collect django static files:
pydev buildjs
Everything what you define after pydev alias will be sent into the command:
ALIASES='{
"run-dj": "project run \"./manage.py\"",
}'
# bash
pydev run-dj migrate --no-input
Will run ./manage.py migrate --no-input
on the docker instance.
For list of all commands you can run command:
pydev --help
Group of commands or helpers which provides manage pull requests in the Bitbucket service.
pydev bitbucket create-release-pull-request
- create a new pull request to the bitbucket repository
BITBUCKET_USERNAME
- username fo the Bitbucket serviceBITBUCKET_PASSWORD
- password to the Bitbucket serviceBITBUCKET_BRANCH_NAME
- pull request destination branch nameBITBUCKET_REPOSITORY
- name of the destination repository
Docker utilities helping with managing docker in your project:
pydev docker login
- login to the docker registrypydev docker tag
- tag a docker imagepydev docker push-image
- push image to the docker repository
Helpers to run git commands which simplify releasing.
pydev git create-release-branch
- create a release branch and push it to the remote repository if the remote name is specifiedpydev git create-deployment-branch
- create a deployment branch and new commit to trigger a deployment eventpydev git checkout-to-release-branch
- checkout git repository back to the release branch from deployment branchpydev git bump-version-from-release-branch
- get version defined in the release branch and bump version filespydev git commit-version
- commit version files and add git tag to the commitpydev git merge-release-branch
- merge current branch to the selected branchpydev git init-hooks
- initialize git hooks defined in the directory ./.pydev/git/hooks
GIT_REMOTE_NAME
- remote repository nameGIT_BRANCH_NAME
- source branch name for create-release-branch command
Helpers for GitLab management.
pydev git create-release-merge-request
- create a new merge request in a GitLab project. It is often used after the project release
GITLAB_API_URL
- URL to gitlab API serviceGITLAB_PROJECT
- GitLab project nameGITLAB_TARGET_BRANCH
- target branch for the merge requestGITLAB_TOKEN
- GitLab authentication token
Helpers for python project quality assurance.
pydev qa all
- run all QA checkspydev qa missing-migrations
- run a missing Django migrations QA check. It will try to generate a Django migrations if there is one or more missing check is failedpydev qa migration-filenames
- run migration filenames QA check. Migration name should be in format "[0-9]{4}_migration.py" (ex. 0001_migration.py)pydev qa missing-translations
- run missing translations QA check. It will try to generate a Djangomakemessages
if there is one or more missing check is failedpydev qa import-order
- run import order QA check. It will check if all the new python code imports have the right order defined with isort commandpydev qa test-method-names
- runs test method names QA check. It will check if the new test methods has the right name in format defined inQA_DISALLOWED_TEST_METHOD_REGEXP
setting
QA_DISALLOWED_TEST_METHOD_REGEXP
- your disallowed test method regex. Example:"def (test_should_[^\(]+)\("
Helpers for automatic update version in the version file.
pydev version bump-to-next
- bump version in the JSON file (or files) and print itpydev version print-version
- return current project version according to version JSON filepydev version print-next
- return next version according to input release type, build hash and version JSON file
VERSION_FILES
- path to the files containing information about project version. There can be more paths which are split with character,
.
You can run shell commands with this utility:
pydev sh ls
The utility can be used in the ALIASES
.
Helpers for AWS ECS management.
pydev ecs deploy-new-task-definition
- deploy new task definition in AWS ECS. This command also updates the service and forces new deploymentpydev ecs register-new-task-definition
- register new task definition in AWS ECSpydev ecs update-service-to-latest-task-definition
- update service with the latest available task_definitionpydev ecs stop-service
- stop an AWS ECS service by updating its desiredCount to 0pydev ecs start-service
- start an AWS ECS service by updating its desiredCount to 0pydev ecs start-cluster-services
- start an AWS ECS service by updating its desiredCount to 0pydev ecs start-services
- start an AWS ECS service by updating its desiredCount to 0pydev ecs run-task
- run a single task in AWS ECSpydev ecs run-task-and-wait-for-success
- run a single task in AWS ECS and wait for it to stop with successpydev ecs run-service-task
- run a single task based on service's task definition in AWS ECS and wait for it to stop with successpydev ecs run-service-task-fargate
- run a single task based on service's task definition in AWS ECS and wait for it to stop with successpydev ecs get-tasks-for-service
- return list of tasks running under specified servicepydev ecs get-task-definition-for-service
- return task definition arn for specified servicepydev ecs stop-service-and-wait-for-tasks-to-stop
- stop service and wait for the tasks to stoppydev ecs stop-services-and-wait-for-tasks-to-stop
- stop services and wait for the tasks to stoppydev ecs get-services-names
- get names of the cluster servicespydev ecs redeploy-services
- redeploy services by forcing new service deploymentpydev ecs redeploy-cluster-services
- redeploy all cluster services by forcing new service deploymentpydev ecs wait-for-services-stable
- wait until all non-daemon services in cluster are stable
AWS_REGION
- your AWS regionAWS_ECS_CLUSTER
- name of your AWS ECS cluster
Helpers for Jira management.
pydev git my-issues
- list issue of the current user according to JQL querypydev git get-branch-name
- generates a new branch name according to the Jira issuepydev git show-issue
- open an issue with the key in a web browserpydev git log-issue-time
- log a spend time to the issue in the Jira worklogpydev git print-issue-worklog
- print Jira issue worklogpydev git invoke-issues-transition
- invoke Jira transition defined with transition name which may change Jira issues status.
JIRA_URL
- URL to the Jira applicationJIRA_USERNAME
- Username for access to the JiraJIRA_API_KEY
- API key to the JiraJIRA_JQL
- JQL for issue listing. Defaut value is:
'project = {project_key} and assignee = currentUser() and status not in ("Done", "Canceled", "Closed") and sprint != null order by created DESC'
JIRA_PROJECT_KEY
- key of the project in the Jira
Helpers for time tracking with toggle service.
pydev toggle start
- start the Toggle timer with description in workspace ID and project IDpydev toggle stop
- stops currently running the Toggl timerpydev toggle print-toggl
- print detail of the currently running Toggle timerpydev toggle print-report
- print summary from the Toggle time tracker. Data can be filtered according to workspace, project, description or by date and timepydev toggle print-report-tasks
- print tracked the Toggle tasks one by one in table. Data can be filtered according to workspace, project, description or by date and time
TOGGL_API_KEY
- the Toggle access API keyTOGGL_PROJECT_ID
- the Toggle project identifierTOGGL_WORKSPACE_ID
- the Toggle workspace ID
Group of commands which joins previous commands for simplifier development.
pydev project set-domain
- set local hostname translation to localhost. It updates/etc/hosts
headers according to input domainpydev project build
- build docker container via compose file and name it with the project namepydev project run
- run one time command on docker container defined in compose file. You can specify image environment variablespydev project exec-command
- run command on already executed docker container defined in compose filepydev project up
- builds, (re)creates, starts, and attaches to containers for a service defined in compose filepydev project stop
- stop all the docker containers from the compose filepydev project install
- builds, (re)creates, starts, and attaches to containers for a service defined in compose filepydev project copy-container-dirs
- copy directories from a docker image to the hostpydev project bind-library
- mount a directory to an another location on docker host with bindfspydev project kill-all
- kill all running docker instancespydev project clean
- clean docker images and its volumes. If you want to clean all the images and volumes use parameter -apydev project task start
- get information from Jira about issue and start Toggle timerpydev project task stop
- stop Toggle timer and logs time to the Jira issuepydev project task create-branch-from-issue
- create a new git branch from the source branch with name generated from the Jira issuepydev project task create-or-update-pull-request
- create a Bitbucket pull request named according to the Jira issuepydev project task sync-timer-log-to-issues
- synchronize logged time in Toggle timer with issues worklog in Jirapydev project task print-last-commit-build
- print the last commit test results in Bitbucket of the selected branch
PROJECT_DOCKER_COMPOSE_PROJECT_NAME
- project name which be used as a prefix aff all builded docker images with composePROJECT_DOCKER_COMPOSE_FILES
- list of the paths to the compose files separated by a character,
PROJECT_DOMAINS
- list of the project domain names separated by a character,
PROJECT_DOCKER_COMPOSE_CONTAINERS
- list of all your docker container names separated by a character,
PROJECT_DOCKER_COMPOSE_DEFAULT_UP_CONTAINERS
- list of docker container names separated by a character,
which will be by default started with commandpydev project up
PROJECT_DOCKER_COMPOSE_VAR_DIRS
- list of your variable directories which will be created before project buildPROJECT_DOCKER_COMPOSE_CONTAINERS_DIR_TO_COPY
- container dir which will be copied after build in formatDOCKER_CONTAINER_NAME:CONTAINER_DIRECTORY:HOST_DIRECTORY
PROJECT_DOCKER_COMPOSE_CONTAINERS_INSTALL_COMMAND
- install that will be triggered after project buildPROJECT_LIBRARY_DIR
- the project library directory path on the docker hostPROJECT_SOURCE_BRANCH_NAME
- your project source branch name. By default value is set tonext
Anything what you need to send to Slack.
pydev slack upload-new-migrations
- send all new Django migration files between releases etc. to Slack
SLACK_BOT_TOKEN
- Token to connect Slack. The link how to obtain the token.