handle non-ASCII characters in import path
This commit is contained in:
parent
f5357a9e7b
commit
85ab611632
1 changed files with 19 additions and 2 deletions
|
@ -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))
|
||||||
|
|
Loading…
Reference in a new issue