Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying fix cmd check #7

Merged
4 commits merged into from
Jun 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions util/Data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import datetime
import json
import os
from sys import exit
from sys import argv, exit
from time import sleep

import inquirer
Expand Down Expand Up @@ -60,13 +60,18 @@ def QRGenerate(self, url: str, img_path: str) -> None:
parent_pid = psutil.Process(os.getpid()).ppid()
parent_process = psutil.Process(parent_pid)
parent_name = parent_process.name()
print(argv)
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
parent_name = ""

if parent_name == "powershell.exe" or "WT_SESSION" in os.environ:
qr.print_ascii(invert=True)
elif parent_name == "cmd.exe":
img.show()
logger.error("获取父进程信息失败!")
sleep(5)
exit()
if os.name == "nt":
if parent_name == "powershell.exe" or "WT_SESSION" in os.environ:
qr.print_ascii(invert=True)
elif parent_name == "cmd.exe" or len(argv) == 1 and not argv[0].endswith(".py"):
img.show()
else:
qr.print_ascii(invert=True)
else:
qr.print_ascii(invert=True)

Expand Down