Skip to content

Commit 1775077

Browse files
committed
Do OS check only once
1 parent bb90977 commit 1775077

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

app.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
from subprocess import Popen, PIPE, STDOUT
1515
from multiprocessing import Pool, cpu_count
1616

17+
is_linux = True
18+
19+
if os.name == "nt":
20+
is_linux = False
21+
1722
# Configure Flask App
1823
app = Flask(__name__)
1924
app.config['SECRET_KEY'] = 'secret!'
@@ -163,13 +168,13 @@ def process_error(error):
163168

164169
# Detect OS
165170
line_num = None
166-
if os.name == "nt":
167-
line_num = error.split(":")[2]
168-
else:
171+
if is_linux:
169172
try:
170173
line_num = error.split(":")[1]
171174
except Exception as e:
172175
print(os.name + " not compatible: " + e)
176+
else:
177+
line_num = error.split(":")[2]
173178

174179
# list_words.pop(0)
175180
error_yet = False

0 commit comments

Comments
 (0)