handle non-ASCII characters in import path

This commit is contained in:
Alan Hamlett 2015-07-27 14:59:10 -07:00
parent f5357a9e7b
commit 85ab611632

View file

@ -11,8 +11,25 @@
import os import os
import sys import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# get path to local wakatime package
package_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# add local wakatime package to sys.path
sys.path.insert(0, package_folder)
# import local wakatime package
try:
import wakatime import wakatime
except TypeError:
# on Windows, non-ASCII characters in import path can be fixed using
# the script path from sys.argv[0].
# More info at https://github.com/wakatime/wakatime/issues/32
package_folder = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
sys.path.insert(0, package_folder)
import wakatime
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(wakatime.main(sys.argv)) sys.exit(wakatime.main(sys.argv))