diff --git a/core/__init__.py b/core/__init__.py index fc2bb97..a41e0e5 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -1,4 +1,6 @@ import math +import os +import sys import numpy as np from stl import mesh @@ -11,6 +13,13 @@ from .utils import * +def get_current_executable_directory(): + if getattr(sys, 'frozen', False): + return os.path.dirname(os.path.realpath(sys.executable)) + + return os.getcwd() + + def process_github_stats(username, year, filename): contributions = get_contributions(username, year) contribution_array = generate_contribution_array(contributions) @@ -23,7 +32,11 @@ def process_github_stats(username, year, filename): to_export = mesh.Mesh(numpy.concatenate([body.data, letters.data, year_obj.data, github_logo.data])) to_export.rotate([0, 0, 1], math.radians(180)) - to_export.save(filename) + path = os.path.join( + get_current_executable_directory(), filename + ) + + to_export.save(path) def process_text(text, filename):