Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules/
.env
.env.example
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
PACKET_IP=0.0.0.0
PACKET_SERVER_NAME=localhost.localdomain:8000
PACKET_SERVER_NAME=localhost:8000
PACKET_DATABASE_URI=postgresql://postgres:mysecretpassword@postgres:5432/postgres
PACKET_OIDC_CLIENT_ID=develop
PACKET_OIDC_CLIENT_SECRET=
PACKET_LDAP_BIND_PASS=
PACKET_LDAP_BIND_DN=
78 changes: 0 additions & 78 deletions .github/workflows/deploy.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
python-version: [3.9]
python-version: [3.14]

steps:
- name: Install ldap dependencies
Expand All @@ -38,7 +38,7 @@ jobs:

strategy:
matrix:
python-version: [3.9]
python-version: [3.14]

steps:
- name: Install ldap dependencies
Expand Down
35 changes: 12 additions & 23 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
[MASTER]
ignore = ,input
persistent = yes
load-plugins = pylint_quotes

[MESSAGES CONTROL]
disable =
missing-docstring,
fixme,
duplicate-code,
no-member,
parse-error,
bad-continuation,
too-few-public-methods,
global-statement,
cyclic-import,
locally-disabled,
file-ignored,
no-else-return,
unnecessary-lambda
fixme,
duplicate-code,
no-member,
parse-error,
too-few-public-methods,
global-statement,
cyclic-import,
locally-disabled,
file-ignored,
no-else-return,
unnecessary-lambda

[REPORTS]
output-format = text
files-output = no
reports = no

[FORMAT]
max-line-length = 120
max-statement-lines = 75
single-line-if-stmt = no
no-space-check = trailing-comma,dict-separator
max-module-lines = 1000
indent-string = ' '
string-quote=single-avoid-escape
triple-quote=single
docstring-quote=double

[MISCELLANEOUS]
notes = FIXME,XXX,TODO
Expand Down Expand Up @@ -79,9 +71,6 @@ good-names=logger,id,ID
# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata

# List of builtins function names that should not be used, separated by a comma
bad-functions=apply,input

[DESIGN]
max-args = 10
ignored-argument-names = _.*
Expand All @@ -95,4 +84,4 @@ min-public-methods = 2
max-public-methods = 20

[EXCEPTIONS]
overgeneral-exceptions = Exception
overgeneral-exceptions = builtins.Exception
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/python:3.9-slim-trixie
FROM docker.io/python:3.14-slim-trixie

RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
RUN apt-get -yq update && \
Expand Down Expand Up @@ -32,4 +32,4 @@ RUN gulp production && \
# Set version for apm
RUN echo "export DD_VERSION=\"$(python3 packet/git.py)\"" >> /tmp/version

CMD ["/bin/bash", "-c", "source /tmp/version && ddtrace-run gunicorn packet:app --bind=0.0.0.0:8080 --access-logfile=- --timeout=600"]
CMD ["/bin/bash", "-c", "source /tmp/version && gunicorn packet:app --bind=0.0.0.0:8080 --access-logfile=- --timeout=600"]
34 changes: 0 additions & 34 deletions Dockerfile.dev

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ the second major iteration of packet on the web. The first version was
2. Build the dev environment with `docker compose build`
3. Start the dev environment with `docker compose up`
4. Run the database migrations with `docker exec -it packet-packet-1 flask db upgrade`
5. Go check out the app at http://localhost.localdomain:8000
5. Go check out the app at http://localhost:8080

> Useful Tip: use `docker compose up --watch` so that you don't need to rebuild the container every time you want to test a change

Expand Down
2 changes: 1 addition & 1 deletion config.env.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
OIDC_CLIENT_SECRET = environ.get("PACKET_OIDC_CLIENT_SECRET", "PLEASE_REPLACE_ME")

# SQLAlchemy config
SQLALCHEMY_DATABASE_URI = environ.get("PACKET_DATABASE_URI", "postgresql://postgres:mysecretpassword@localhost:5432/postgres")
SQLALCHEMY_DATABASE_URI = environ.get("PACKET_DATABASE_URI", "postgresql://postgres:mysecretpassword@postgres:5432/postgres")
SQLALCHEMY_TRACK_MODIFICATIONS = False

# LDAP config
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ services:
packet:
build:
context: .
dockerfile: ./Dockerfile.dev
env_file:
- path: ".env"
required: true
ports:
- "8000:8000"
- "8080:8080"
develop:
watch:
- action: sync+restart
Expand All @@ -23,14 +22,15 @@ services:
postgres:
condition: service_healthy
restart: true

postgres:
image: "docker.io/postgres:17"
image: docker.io/postgres
networks:
- packet-network-dev
environment:
POSTGRES_USER: "postgres"
POSTGRES_DB: "postgres"
POSTGRES_PASSWORD: "mysecretpassword"
POSTGRES_USER: postgres
POSTGRES_DATABASE: postgres
POSTGRES_PASSWORD: mysecretpassword
ports:
- "5432:5432"
healthcheck:
Expand Down
7 changes: 4 additions & 3 deletions packet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@

# Logger configuration
logging.getLogger().setLevel(app.config['LOG_LEVEL'])
app.logger.info('Launching packet ' + app.config['VERSION'])
app.logger.info('Using the {} realm'.format(app.config['REALM']))
app.logger.info('Launching packet %s', app.config['VERSION'])
app.logger.info('Using the %s realm', app.config['REALM'])

# Initialize the extensions
db = SQLAlchemy(app)
migrate = Migrate(app, db)
app.logger.info('SQLAlchemy pointed at ' + repr(db.engine.url))
with app.app_context():
app.logger.info('SQLAlchemy pointed at %s', repr(db.engine.url))

APP_CONFIG = ProviderConfiguration(issuer=app.config['OIDC_ISSUER'],
client_metadata=ClientMetadata(app.config['OIDC_CLIENT_ID'],
Expand Down
38 changes: 18 additions & 20 deletions packet/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, row: list[str]) -> None:
def parse_csv(freshmen_csv: str) -> dict[str, CSVFreshman]:
print('Parsing file...')
try:
with open(freshmen_csv, newline='') as freshmen_csv_file:
with open(freshmen_csv, newline='', encoding="locale") as freshmen_csv_file:
return {freshman.rit_username: freshman for freshman in map(CSVFreshman, csv.reader(freshmen_csv_file))}
except Exception as e:
print('Failure while parsing CSV')
Expand Down Expand Up @@ -108,34 +108,32 @@ def fetch_results(file_path: str, use_csv: bool, date_str: str) -> None:
end_date = datetime.combine(input_date("Enter the last day of the packet season you'd like to retrieve results "
'from'), packet_end_time)


file_handle = open(file_path, 'w', newline='') if file_path else sys.stdout

column_titles = ['Name (RIT Username)', 'Upperclassmen Score', 'Total Score', 'Upperclassmen', 'Freshmen',
'Miscellaneous', 'Total Missed']
data = list()
data = []
for packet in Packet.query.filter_by(end=end_date).all():
received = packet.signatures_received()
required = packet.signatures_required()

row = [
'{} ({}):'.format(packet.freshman.name, packet.freshman.rit_username),
'{:0.2f}%'.format(received.member_total / required.member_total * 100),
'{:0.2f}%'.format(received.total / required.total * 100),
'{}/{}'.format(received.upper, required.upper),
'{}/{}'.format(received.fresh, required.fresh),
'{}/{}'.format(received.misc, required.misc),
required.total - received.total,
f'{packet.freshman.name} ({packet.freshman.rit_username}):',
f'{received.member_total / required.member_total * 100:0.2f}%',
f'{received.total / required.total * 100:0.2f}%',
f'{received.upper}/{required.upper}',
f'{received.fresh}/{required.fresh}',
f'{received.misc}/{required.misc}',
required.total - received.total,
]
data.append(row)

if use_csv:
writer = csv.writer(file_handle)
writer.writerow(column_titles)
writer.writerows(data)
else:
for row in data:
file_handle.write(f'''
with open(file_path, 'w', newline='', encoding='locale') if file_path else sys.stdout as file_handle:
if use_csv:
writer = csv.writer(file_handle)
writer.writerow(column_titles)
writer.writerows(data)
else:
for row in data:
file_handle.write(f'''

{row[0]}
\t{column_titles[1]}: {row[1]}
Expand All @@ -160,7 +158,7 @@ def extend_packet(packet_id: int) -> None:
print('Packet is already closed so it cannot be extended')
return
else:
print('Ready to extend packet #{} for {}'.format(packet_id, packet.freshman_username))
print(f'Ready to extend packet #{packet_id} for {packet.freshman_username}')

packet.end = datetime.combine(input_date('Enter the new end date for this packet'), packet_end_time)
db.session.commit()
Expand Down
11 changes: 7 additions & 4 deletions packet/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def log_time(label: str) -> None:

@app.context_processor
def utility_processor() -> dict[str, Callable]:
return dict(
get_csh_name=get_csh_name, get_rit_name=get_rit_name, get_rit_image=get_rit_image, log_time=log_time,
get_roles=get_roles
)
return {
"get_csh_name": get_csh_name,
"get_rit_name": get_rit_name,
"get_rit_image": get_rit_image,
"log_time": log_time,
"get_roles": get_roles
}
2 changes: 1 addition & 1 deletion packet/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_version(commit_ish: str = 'HEAD') -> str:
return sha
else:
root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
with open(os.path.join(root_dir, 'package.json')) as package_file:
with open(os.path.join(root_dir, 'package.json'), encoding='locale') as package_file:
return json.load(package_file)['version']

if __name__ == '__main__':
Expand Down
Loading
Loading