Skip to content

Commit

Permalink
Added lint black and pre-commit (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
glaubervila authored Feb 7, 2024
1 parent 429e7b4 commit e05300f
Show file tree
Hide file tree
Showing 345 changed files with 9,416 additions and 15,130 deletions.
5 changes: 2 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
python3-dev \
libaio-dev \
build-essential \
libcfitsio-bin \
libcfitsio-bin \
libsasl2-dev \
libldap2-dev \
libssl-dev \
Expand All @@ -18,7 +18,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get clean \
&& apt-get autoclean \
&& apt-get autoremove --purge -y \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/*

# [Optional] If your requirements rarely change, uncomment this section to add them to the image.
COPY ./backend/requirements.txt /tmp/pip-tmp/
Expand All @@ -32,4 +32,3 @@ ENV DJANGO_SETTINGS_MODULE=coreAdmin.settings
# COPY --chmod=0775 ./backend/start.sh /start.sh

# ENTRYPOINT ["/entrypoint.sh"]

2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers-contrib/features/black:2": {},
"ghcr.io/devcontainers-contrib/features/coverage-py:2": {},
Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ version: '3.6'
services:
# Update this to the name of the service you want to work with in your docker-compose.yml file
vscode:
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
# array). The sample below assumes your primary file is in the root of your project.
#
Expand All @@ -27,4 +27,4 @@ services:
# - seccomp:unconfined

# Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done"
command: /bin/sh -c "while sleep 1000; do :; done"
6 changes: 3 additions & 3 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
type=sha,format=short,prefix=frontend_
flavor: |
latest=auto
prefix=frontend_,onlatest=true
prefix=frontend_,onlatest=true
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
context: ./predict_occultation
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}

build_pipelines:

Expand Down Expand Up @@ -179,4 +179,4 @@ jobs:
context: ./pipelines
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-toml
- id: check-xml
- id: check-yaml
# - id: debug-statements
# - id: check-builtin-literals
# exclude: ^pipelines/
- id: check-case-conflict
- id: check-docstring-first
- id: detect-private-key
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
exclude: ^pipelines/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 LIneA IT
Copyright (c) 2018 LIneA IT

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Value of TAI-UTC in second valid beetween the initial value until
# the epoch given on the next line. The last line reads that NO
# leap second was introduced since the corresponding date
# leap second was introduced since the corresponding date
# Updated through IERS Bulletin 64 issued in July 2022
#
#
#
# File expires on 28 June 2023
#
#
# MJD Date TAI-UTC (s)
# day month year
# --- -------------- ------
# --- -------------- ------
#
41317.0 1 1 1972 10
41499.0 1 7 1972 11
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat
https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat
7 changes: 3 additions & 4 deletions backend/.astropy/config/astropy.4.1.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

## The file to log messages to. If empty string is given, it defaults to a
## file ``'astropy.log'`` in the astropy config directory.
# log_file_path =
# log_file_path =

## Threshold for logging messages to `log_file_path`.
# log_file_level = INFO
Expand All @@ -87,7 +87,7 @@

## The encoding (e.g., UTF-8) to use for the log file. If empty string is
## given, it defaults to the platform-preferred encoding.
# log_file_encoding =
# log_file_encoding =

[nddata]

Expand Down Expand Up @@ -204,7 +204,7 @@
# remote_timeout = 10.0

## System file with leap seconds.
# system_leap_second_file =
# system_leap_second_file =

## URL for auto-downloading leap seconds.
# iers_leap_second_auto_url = https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat
Expand All @@ -226,4 +226,3 @@

## The grid size to use when drawing a grid using contours
# contour_grid_samples = 200

7 changes: 3 additions & 4 deletions backend/.astropy/config/astropy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

## The file to log messages to. If empty string is given, it defaults to a
## file ``'astropy.log'`` in the astropy config directory.
# log_file_path =
# log_file_path =

## Threshold for logging messages to `log_file_path`.
# log_file_level = INFO
Expand All @@ -87,7 +87,7 @@

## The encoding (e.g., UTF-8) to use for the log file. If empty string is
## given, it defaults to the platform-preferred encoding.
# log_file_encoding =
# log_file_encoding =

[nddata]

Expand Down Expand Up @@ -204,7 +204,7 @@
# remote_timeout = 10.0

## System file with leap seconds.
# system_leap_second_file =
# system_leap_second_file =

## URL for auto-downloading leap seconds.
# iers_leap_second_auto_url = https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat
Expand All @@ -226,4 +226,3 @@

## The grid size to use when drawing a grid using contours
# contour_grid_samples = 200

2 changes: 1 addition & 1 deletion backend/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "tnouser"
}
}
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ USER tnouser

# NÃO adicionar o script /start.sh no entrypoint
# O /start.sh deve ser adicionado no docker-compose command.
ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
9 changes: 4 additions & 5 deletions backend/common/docker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Funcoes para converter as estatisticas de um container,
retiradas deste repositorio: https://github.com/TomasTomecek/sen/blob/master/sen/util.py#L162
"""
import os
import logging
import functools
Expand All @@ -7,11 +11,6 @@

from docker.errors import APIError

"""
Funcoes para converter as estatisticas de um container,
retiradas deste repositorio: https://github.com/TomasTomecek/sen/blob/master/sen/util.py#L162
"""


# this is taken directly from docker client:
# https://github.com/docker/docker/blob/28a7577a029780e4533faf3d057ec9f6c7a10948/api/client/stats.go#L309
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@
</table>
</body>

</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@
</table>
</body>

</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@
</table>
</body>

</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@
</table>
</body>

</html>
</html>
2 changes: 1 addition & 1 deletion backend/common/templates/notification_skybot_abort.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@
</table>
</body>

</html>
</html>
2 changes: 1 addition & 1 deletion backend/common/templates/notification_skybot_fail.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@
</table>
</body>

</html>
</html>
2 changes: 1 addition & 1 deletion backend/common/templates/notification_skybot_finish.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,4 @@
</table>
</body>

</html>
</html>
2 changes: 1 addition & 1 deletion backend/common/templates/notification_skybot_start.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ <h1 style="font-family: Bitter, Georgia, serif; font-size: 16px; font-weight: bo
</table>
</body>

</html>
</html>
21 changes: 10 additions & 11 deletions backend/common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from rest_framework.decorators import action, api_view
from rest_framework.response import Response


@api_view(["GET"])
def teste(request):
if request.method == "GET":
Expand All @@ -18,11 +19,13 @@ def teste(request):
from datetime import datetime, timezone
from tno.models import Occultation

lat=-22.90278
long=-43.2075
radius=50
lat = -22.90278
long = -43.2075
radius = 50

events = Occultation.objects.filter(date_time__date='2023-08-01', have_path_coeff=True)
events = Occultation.objects.filter(
date_time__date="2023-08-01", have_path_coeff=True
)

rows = []
ids = []
Expand All @@ -31,20 +34,16 @@ def teste(request):
latitude=float(lat),
longitude=float(long),
radius=float(radius),
date_time= e.date_time.isoformat(),
inputdict= e.occultation_path_coeff,
date_time=e.date_time.isoformat(),
inputdict=e.occultation_path_coeff,
)

# print(f"Occ ID: {e.id} - {e.date_time.isoformat()} - {e.name} IS Visible: [ {is_visible} ] Info: [{info}]")
if is_visible:
rows.append(e)
ids.append(e.id)

result = {
"success": True,
"rows": len(rows),
"ids": ids
}
result = {"success": True, "rows": len(rows), "ids": ids}

return Response(result)

Expand Down
2 changes: 1 addition & 1 deletion backend/coreAdmin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

__all__ = ('celery_app',)
__all__ = ("celery_app",)
Loading

0 comments on commit e05300f

Please sign in to comment.