Skip to content

Commit d5b3ce2

Browse files
committed
Add linux correct path in file open Attempt#3
1 parent 82c7022 commit d5b3ce2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

core/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import math
2+
import os
3+
import sys
24

35
import numpy as np
46
from stl import mesh
@@ -11,6 +13,13 @@
1113
from .utils import *
1214

1315

16+
def get_current_executable_directory():
17+
if getattr(sys, 'frozen', False):
18+
return os.path.dirname(os.path.realpath(sys.executable))
19+
20+
return os.getcwd()
21+
22+
1423
def process_github_stats(username, year, filename):
1524
contributions = get_contributions(username, year)
1625
contribution_array = generate_contribution_array(contributions)
@@ -23,7 +32,11 @@ def process_github_stats(username, year, filename):
2332
to_export = mesh.Mesh(numpy.concatenate([body.data, letters.data, year_obj.data, github_logo.data]))
2433
to_export.rotate([0, 0, 1], math.radians(180))
2534

26-
to_export.save(filename)
35+
path = os.path.join(
36+
get_current_executable_directory(), filename
37+
)
38+
39+
to_export.save(path)
2740

2841

2942
def process_text(text, filename):

0 commit comments

Comments
 (0)