Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am attending a coding bootcamp and python is the primary language. For the final project, we were told to study and learn how to create console apps. I have searched online for tutorials and books but none seems to have beginner content. Where can I get the best tutorial on creating Python console apps? I have only done python for a month.
Argparse for parsing command line arguments :
https://docs.python.org/3/library/argparse.html
Then for input you can use input(), or maybe curses.
https://docs.python.org/3/library/curses.html
Curses is a really powerful tool.
As an example here's htop that uses ncurses :
http://hisham.hm/htop/
Using sys.stdin.readlines() you can get the data that has been passed to your application, exemple :
cat myfile.txt | myapp.py
Then you can render your script executable using chmod +x, and adding a header in your script to the python binaries to use :
#!/usr/bin/python
Then you could create an alias, or add your program to the PATH, so you could use it from anywhere on the system, like ls, cat or whatever you may think of...
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have been making a program that opens a different file (extension is .ebj) and shows you the 3d object saved inside it with pygame, so kind of like a simple programming language. Currently i have found how to choose what file you want to open using sys.argv but is there a way to make it so you can run the .ebj file and it will automatically run the python code with the file you ran as the parameter
You description is a bit difficult to decipher. I think you need your python script to run a file? That's what I'm assuming after seeing your reference to sys.argv as holding the file you'd like to run.
If I have that correct, then how you go about running that file is going to be dependent on which OS you're operating on. I'll assume windows, but forgive me if I'm off on that.
Here's how I have my windows machine run a software package using the windows default application based on the file ext.
import subprocess
filename = GET_YOUR_FILENAME_HERE
subprocess.call("start " + filename, shell=True)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
i have Ubuntu Server machine running Minecraft Server to play with my friends and stuff, but i am bored and i want to make simple python app in console to display server status, like current number of connected players, difficulty, world seed, RAM used and stuff... my question is, if its possible to get this data from MC server application, and if then how. Mainly i am interested about live player data (count, names, probably posotion), chat feed etc.. I didnĀ“t tried anything because i have no idea where to start :D
thanks
-N
Maybe you were looking for something like this:
https://github.com/Dinnerbone/mcstatus
Edit:
The module is named "mcstatus" and provides a "A Python class for checking the status of an enabled Minecraft server".
You can install it via pip: pip install mcstatus
It provides three modes of access (query, status and ping), the differences of which are listed on the page of this link.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am developing a paid program in Python with Tkinter. How can I make the program user-specific. I don't want people sharing their license. If there is no better option than serial keys. What is the best way of doing this? Doesn't have to be top of the line security. Just don't want people to share their license..
You could embed the machine ID and user ID in your code to check at startup.
import getpass
userID = getpass.getuser()
import socket
machineID = socket.gethostname()
Also see (not verified but here it goes): Getting computer hardware information
Also at the Windows command prompt, you can use systeminfo which will give you the whole computer information. From Python you can run os.system('systeminfo > lolo.txt') which will display and pipe to the text file.
I was looking a the same problem you have. Hope it helps
If you want to use python to write code, but keep embedded secrets, your best bet will be to compile to binary and ship only binary to users. PyInstaller is a good place to start your research. There are several alternatives to PyInstaller.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I searched a lot, but couldn't find any precise answer to my question. I would like to programmatically be able to simulate user interactions with the computer. I would like to target OSX since that's what I am working on. For example, I would launch Dashboard or Mission Control, move the mouse and click on things, open a keyboard, etc.
I wonder if I should use Linux with Xlib or something like that... Would I be more free to execute these kinds of operations? And do you know any libraries that allow them easily, in Python preferably?
This kind of software is called a "robot", or "ui automation", which makes googling a little difficult. Here is one in python: http://code.google.com/p/robotframework/
I like to use Sikuli for this sort of thing. Last time I needed to automate a GUI app on OS X, I wrote a standalone Jython script which used Sikuli as a library.
You can also use the Sikuli IDE if you want to get something working quickly, which can be nice for experimentation.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Can I know this information across python?, for example, the name of the card graphic, processor, audio, mother board ....
There isn't anything in Python itself. You can detect what OS you're on via the platform module. Otherwise
See also:
How can I return system information in Python?
If you're on Windows, you can probably use PyWin32 to get some of this information. See the following recipe to get an idea of some of the stuff you can get:
http://code.activestate.com/recipes/511491-getting-system-information-under-windows/
I also wrote a little about this regarding getting Windows system information here:
http://www.blog.pythonlibrary.org/2010/01/27/getting-windows-system-information-with-python/
You might be able to use HAL:
http://www.daniweb.com/software-development/python/threads/300786/how-to-get-graphics-card-details-in-python
I have also found the psutil project very helpful. I also came across PyCPU, although I'm unsure what its status is.
For Linux (and probably Mac), you'll probably have to use system commands called via Python's subprocess module and parse the result(s).