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

Pytocs not converting msvcrt.getch to Console.ReadKey #55

Open
eric645 opened this issue May 30, 2019 · 2 comments
Open

Pytocs not converting msvcrt.getch to Console.ReadKey #55

eric645 opened this issue May 30, 2019 · 2 comments

Comments

@eric645
Copy link

eric645 commented May 30, 2019

I found "getch()" in a C# file generated by Py To Cs.

@uxmal
Copy link
Owner

uxmal commented May 31, 2019

Could you provide me with a small code fragment that shows me how the call to getch() is being made in your Python source code?

@eric645
Copy link
Author

eric645 commented Jun 4, 2019

Script Downloader

from sys import argv
from requests import get
from os import path, getcwd, startfile
from getpass import getuser
from sys import stderr
from msvcrt import getch
for i in range(len(open(argv[1]).readlines())):
    n = open(argv[1]).readlines()[i].split()
    if n[0] == "download":
        drive, paf = path.splitdrive(n[1])
        path, file = path.split(paf)
        del paf, drive, path
        netpath = n[1]
        drive, p = path.splitdrive(getcwd())
        del p
        locpath = path.join(drive, "Users\\" + getuser() + "\\Downloads\\" + file)
        open(locpath, 'w').write(get(netpath))
        lpipk = locpath
    elif n[0] == "open":
        if lpipk != "":
            startfile(lpipk)
        else:
            stderr.write("ERROR: Did not download in session before running the command")
    elif n[0] == "exit":
        try:
            quit(int(n[1]))
        except TypeError:
            stderr.write("ERROR: exit command argument 1: NaN")
            getch()
            quit()
        except IndexError:
            quit()
    else:
        stderr.write("ERROR: Unexpected command\n  " + ' '.join(n))

getch() is in an exception handler except TypeError:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants