Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning up code for codacy #74

Merged
merged 1 commit into from
May 8, 2024
Merged
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
16 changes: 11 additions & 5 deletions agvis/static/js/TimeBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ L.SimTimeBox = L.Control.extend({
* @returns
*/
onAdd: function(map) {
this.simulation_time = 0;
this.text = L.DomUtil.create('div');
this.text.id = "info_text";
this.text.innerHTML = "<p style=\"font-size:250%;\"><strong>Simulation time:</strong> " + this.simulation_time + "</p>";
return this.text;
if (typeof L !== 'undefined') {
this.simulation_time = 0;
this.text = L.DomUtil.create('div');
this.text.id = "info_text";
this.text.innerHTML = "<p style=\"font-size:250%;\"><strong>Simulation time:</strong> " + this.simulation_time + "</p>";
return this.text;
}
else {
console.error("Leaflet not found.");
return null;
}
},

/**
Expand Down
8 changes: 5 additions & 3 deletions agvis/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import sys
import subprocess
from flask import Flask, render_template, send_from_directory
from .flask_configurations import *
from .flask_configurations import DefaultConfig
from .flask_configurations import DevelopmentConfig
from .flask_configurations import ProductionConfig
import requests

class AgvisWeb():
Expand Down Expand Up @@ -71,7 +73,7 @@ def run(self, host='localhost', port=8810, workers=1, dev=False):
dev = True

# Run flask as a development server
if (dev == True):
if (dev):
self.app.config.from_object(DevelopmentConfig())

command = [
Expand All @@ -95,7 +97,7 @@ def run(self, host='localhost', port=8810, workers=1, dev=False):
]

# Start the application
with self.app.requests_session as session:
with self.app.requests_session:
subprocess.run(command, check=True, cwd=self.app_dir)

except KeyboardInterrupt:
Expand Down
5 changes: 2 additions & 3 deletions go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ piptrustedhost=

build() {
# Set Agvis Branch
local BRANCH_NAME=master
local BRANCH_NAME="master"
if [ "$1" ]; then
BRANCH_NAME=$1
fi
Expand All @@ -47,7 +47,7 @@ build() {
${target:+--target $target} \
${pipindex:+--build-arg PIP_INDEX_URL=$pipindex} \
${piptrustedhost:+--build-arg PIP_TRUSTED_HOST=$piptrustedhost} \
--build-arg BRANCH_NAME=$BRANCH_NAME \
--build-arg BRANCH_NAME="$BRANCH_NAME" \
-t $tag .
}

Expand All @@ -57,7 +57,6 @@ run_tests() {

dev2() {
google-chrome --incognito http://localhost:8810/ 2> /dev/null > /dev/null &

tmux split-window -v
tmux split-window -v
tmux select-layout tiled
Expand Down
4 changes: 4 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def mock_subprocess_run(c2, **kwargs):
with capsys.disabled(), pytest.raises(SystemExit):
main()

# ================================================================================
# DISABLED: This test runs different locally than on GitHub Actions
# ================================================================================

# def test_agvis_run_invalid_command(monkeypatch, capsys):
# c1 = "agvis invalid_command"

Expand Down
2 changes: 0 additions & 2 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# ================================================================================

import os, os.path
import pytest
from tests.conftest import client

def test_index(client):
response = client.get('/')
Expand Down