Skip to content

Commit

Permalink
Merge pull request #11 from anexia-it/async
Browse files Browse the repository at this point in the history
Move to updatable 0.7 and asyncio
  • Loading branch information
nezhar authored Aug 23, 2022
2 parents 79fbf0e + 586c1b6 commit 61cb919
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ jobs:
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
django-version: ['3.2', '4.0']
django-version: ['3.2', '4.0', '4.1']
exclude:
- python-version: '3.7'
django-version: '4.0'
- python-version: '3.7'
django-version: '4.1'

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 2 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.5.0 - Unreleased]

### Added
-
- Support for Django 4.1

### Changed
-

### Removed
-
- Pin updatable to `>=0.7`

## [1.4.1]

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ website is alive and working correctly.
Django Compatibility Matrix
---------------------------

If your project uses an older verison of Django, you can choose an older version of this project.
If your project uses an older version of Django, you can choose an older version of this project.

| This Project | Python Version | Django Version |
|--------------|----------------|----------------|
| 1.5.* | 3.7 - 3.10 | 3.2, 4.0, 4.1 |
| 1.4.* | 3.7 - 3.10 | 3.2, 4.0 |
| 1.3.* | 3.5 - 3.9 | 2.2, 3.1, 3.2 |
| 1.2.* | 3.5 - 3.8 | 2.2, 3.0, 3.1 |
Expand Down
39 changes: 22 additions & 17 deletions anexia_monitoring/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
import asyncio
import sys

from updatable import get_package_update_list, get_parsed_environment_package_list

from django.http import JsonResponse, HttpResponse
Expand Down Expand Up @@ -40,13 +42,24 @@ class MonitorModulesView(BaseView):
of the module. It also contains information about the runtime (python and django version).
"""

@access_token_check
def get(self, request, *args, **kwargs):
async def get_response_data(self):
runtime = {
'platform': 'python',
'platform_version': sys.version,
'framework': 'django',
'framework_installed_version': None,
'framework_newest_version': None,
}
modules = []
packages = get_parsed_environment_package_list()

for package in packages:
package_data = get_package_update_list(package['package'], package['version'])
package['_data'] = asyncio.create_task(
get_package_update_list(package['package'], package['version'])
)

for package in packages:
package_data = await package['_data']

modules.append({
'name': package['package'],
Expand All @@ -61,25 +74,17 @@ def get(self, request, *args, **kwargs):
})

if package['package'] == 'Django':
django_data = {
'installed_version': package['version'],
'newest_version': package_data['latest_release'],
}
runtime['framework_installed_version'] = package['version']
runtime['framework_newest_version'] = package_data['latest_release']

runtime = {
'platform': 'python',
'platform_version': sys.version,
'framework': 'django',
'framework_installed_version': django_data['installed_version'],
'framework_newest_version': django_data['newest_version'],
}

data = {
return {
'runtime': runtime,
'modules': modules,
}

response = JsonResponse(data)
@access_token_check
def get(self, request, *args, **kwargs):
response = JsonResponse(asyncio.run(self.get_response_data()))
self.add_access_control_headers(response)
return response

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
AUTHOR = 'Anexia'
LICENSE = 'MIT'
REQUIRED = [
'updatable>=0.6,<0.7',
'updatable>=0.7',
]
CLASSIFIERS = [
'License :: OSI Approved :: MIT License',
Expand Down

0 comments on commit 61cb919

Please sign in to comment.