1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-20 13:11:47 +00:00

modify path with c2e and c2p (#790)

This commit is contained in:
Alex Xu
2024-12-30 22:19:23 -08:00
committed by GitHub
parent 315b6e150d
commit 4adb998896
3 changed files with 58 additions and 50 deletions

View File

@@ -20,6 +20,8 @@
import sys import sys
from kcc import modify_path
if sys.version_info < (3, 8, 0): if sys.version_info < (3, 8, 0):
print('ERROR: This is a Python 3.8+ script!') print('ERROR: This is a Python 3.8+ script!')
sys.exit(1) sys.exit(1)
@@ -28,6 +30,7 @@ from multiprocessing import freeze_support, set_start_method
from kindlecomicconverter.startup import startC2E from kindlecomicconverter.startup import startC2E
if __name__ == "__main__": if __name__ == "__main__":
modify_path()
set_start_method('spawn') set_start_method('spawn')
freeze_support() freeze_support()
startC2E() startC2E()

View File

@@ -20,6 +20,8 @@
import sys import sys
from kcc import modify_path
if sys.version_info < (3, 8, 0): if sys.version_info < (3, 8, 0):
print('ERROR: This is a Python 3.8+ script!') print('ERROR: This is a Python 3.8+ script!')
sys.exit(1) sys.exit(1)
@@ -28,6 +30,7 @@ from multiprocessing import freeze_support, set_start_method
from kindlecomicconverter.startup import startC2P from kindlecomicconverter.startup import startC2P
if __name__ == "__main__": if __name__ == "__main__":
modify_path()
set_start_method('spawn') set_start_method('spawn')
freeze_support() freeze_support()
startC2P() startC2P()

102
kcc.py
View File

@@ -28,64 +28,66 @@ if sys.version_info < (3, 8, 0):
print('ERROR: This is a Python 3.8+ script!') print('ERROR: This is a Python 3.8+ script!')
sys.exit(1) sys.exit(1)
if platform.system() == 'Darwin': def modify_path():
mac_paths = [ if platform.system() == 'Darwin':
'/Applications/Kindle Comic Creator/Kindle Comic Creator.app/Contents/MacOS', mac_paths = [
'/Applications/Kindle Previewer 3.app/Contents/lib/fc/bin/', '/Applications/Kindle Comic Creator/Kindle Comic Creator.app/Contents/MacOS',
] '/Applications/Kindle Previewer 3.app/Contents/lib/fc/bin/',
if getattr(sys, 'frozen', False): ]
os.environ['PATH'] += os.pathsep + os.pathsep.join(mac_paths + if getattr(sys, 'frozen', False):
[ os.environ['PATH'] += os.pathsep + os.pathsep.join(mac_paths +
'/opt/homebrew/bin', [
'/usr/local/bin', '/opt/homebrew/bin',
'/usr/bin', '/usr/local/bin',
'/bin', '/usr/bin',
] '/bin',
) ]
os.chdir(os.path.dirname(os.path.abspath(sys.executable))) )
else: os.chdir(os.path.dirname(os.path.abspath(sys.executable)))
os.environ['PATH'] += os.pathsep + os.pathsep.join(mac_paths) else:
os.chdir(os.path.dirname(os.path.abspath(__file__))) os.environ['PATH'] += os.pathsep + os.pathsep.join(mac_paths)
os.chdir(os.path.dirname(os.path.abspath(__file__)))
elif platform.system() == 'Linux': elif platform.system() == 'Linux':
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
os.environ['PATH'] += os.pathsep + os.pathsep.join( os.environ['PATH'] += os.pathsep + os.pathsep.join(
[ [
str(Path.home() / ".local" / "bin"), str(Path.home() / ".local" / "bin"),
'/opt/homebrew/bin', '/opt/homebrew/bin',
'/usr/local/bin', '/usr/local/bin',
'/usr/bin', '/usr/bin',
'/bin', '/bin',
] ]
) )
os.chdir(os.path.dirname(os.path.abspath(sys.executable))) os.chdir(os.path.dirname(os.path.abspath(sys.executable)))
else: else:
os.chdir(os.path.dirname(os.path.abspath(__file__))) os.chdir(os.path.dirname(os.path.abspath(__file__)))
elif platform.system() == 'Windows': elif platform.system() == 'Windows':
win_paths = [ win_paths = [
os.path.expandvars('%LOCALAPPDATA%\\Amazon\\KC2'), os.path.expandvars('%LOCALAPPDATA%\\Amazon\\KC2'),
os.path.expandvars('%LOCALAPPDATA%\\Amazon\\Kindle Previewer 3\\lib\\fc\\bin\\'), os.path.expandvars('%LOCALAPPDATA%\\Amazon\\Kindle Previewer 3\\lib\\fc\\bin\\'),
os.path.expandvars('%UserProfile%\\Kindle Previewer 3\\lib\\fc\\bin\\'), os.path.expandvars('%UserProfile%\\Kindle Previewer 3\\lib\\fc\\bin\\'),
'C:\\Apps\\Kindle Previewer 3\\lib\\fc\\bin', 'C:\\Apps\\Kindle Previewer 3\\lib\\fc\\bin',
'D:\\Apps\\Kindle Previewer 3\\lib\\fc\\bin', 'D:\\Apps\\Kindle Previewer 3\\lib\\fc\\bin',
'E:\\Apps\\Kindle Previewer 3\\lib\\fc\\bin', 'E:\\Apps\\Kindle Previewer 3\\lib\\fc\\bin',
'C:\\Program Files\\7-Zip', 'C:\\Program Files\\7-Zip',
'D:\\Program Files\\7-Zip', 'D:\\Program Files\\7-Zip',
'E:\\Program Files\\7-Zip', 'E:\\Program Files\\7-Zip',
] ]
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
os.environ['PATH'] += os.pathsep + os.pathsep.join(win_paths) os.environ['PATH'] += os.pathsep + os.pathsep.join(win_paths)
os.chdir(os.path.dirname(os.path.abspath(sys.executable))) os.chdir(os.path.dirname(os.path.abspath(sys.executable)))
else: else:
os.environ['PATH'] += os.pathsep + os.pathsep.join(win_paths) os.environ['PATH'] += os.pathsep + os.pathsep.join(win_paths)
os.chdir(os.path.dirname(os.path.abspath(__file__))) os.chdir(os.path.dirname(os.path.abspath(__file__)))
from multiprocessing import freeze_support, set_start_method from multiprocessing import freeze_support, set_start_method
from kindlecomicconverter.startup import start from kindlecomicconverter.startup import start
if __name__ == "__main__": if __name__ == "__main__":
modify_path()
set_start_method('spawn') set_start_method('spawn')
freeze_support() freeze_support()
start() start()