1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-11-04 09:22:29 +01:00

Windows EXE: Start Powershell instead of cmd

... if started by file explorer.
This commit is contained in:
Alexander Graf 2020-06-06 10:37:20 +02:00
parent 2fd1422619
commit 1c13d5a30b
2 changed files with 14 additions and 3 deletions

View File

@ -17,7 +17,7 @@ import subprocess
def __main(): def __main():
with contextlib.suppress(AttributeError, psutil.Error): with contextlib.suppress(AttributeError, psutil.Error):
if psutil.Process().parent().parent().name() == "explorer.exe": if psutil.Process().parent().parent().name() == "explorer.exe":
subprocess.Popen("cmd /K \\\"{0}\\\"".format(os.path.splitext(os.path.basename(sys.argv[0]))[0])) subprocess.Popen("powershell -NoExit -Command \\\"& {0}\\\"".format(sys.argv[0]))
return return
main() main()

View File

@ -3,6 +3,7 @@
import ast import ast
import datetime import datetime
import os import os
import platform
import re import re
import sys import sys
from argparse import ArgumentParser, SUPPRESS from argparse import ArgumentParser, SUPPRESS
@ -15,10 +16,20 @@ from .instaloader import get_default_session_filename
from .instaloadercontext import default_user_agent from .instaloadercontext import default_user_agent
def get_simple_argv0() -> str:
if platform.system() != "Windows":
argv0 = os.path.basename(sys.argv[0])
else:
dirname = os.path.relpath(os.path.dirname(sys.argv[0]))
basename = os.path.basename(sys.argv[0])
argv0 = os.path.join(dirname, basename)
argv0 = "instaloader" if argv0 == "__main__.py" else argv0
return argv0
def usage_string(): def usage_string():
# NOTE: duplicated in README.rst and docs/index.rst # NOTE: duplicated in README.rst and docs/index.rst
argv0 = os.path.basename(sys.argv[0]) argv0 = get_simple_argv0()
argv0 = "instaloader" if argv0 == "__main__.py" else argv0
return """ return """
{0} [--comments] [--geotags] {0} [--comments] [--geotags]
{2:{1}} [--stories] [--highlights] [--tagged] [--igtv] {2:{1}} [--stories] [--highlights] [--tagged] [--igtv]