cross-platform

Regular Expression to match cross platform newline characters

Regular Expression to match cross platform newline characters Question: My program can accept data that has newline characters of n, rn or r (eg Unix, PC or Mac styles) What is the best way to construct a regular expression that will match whatever the encoding is? Alternatively, I could use universal_newline support on input, but …

Total answers: 2

Cross-platform subprocess with hidden window

Cross-platform subprocess with hidden window Question: I want to open a process in the background and interact with it, but this process should be invisible in both Linux and Windows. In Windows you have to do some stuff with STARTUPINFO, while this isn’t valid in Linux: ValueError: startupinfo is only supported on Windows platforms Is …

Total answers: 5

Cross-platform way of getting temp directory in Python

Cross-platform way of getting temp directory in Python Question: Is there a cross-platform way of getting the path to the temp directory in Python 2.6? For example, under Linux that would be /tmp, while under XP C:Documents and settings[user]Application settingsTemp. Asked By: Joril || Source Answers: That would be the tempfile module. It has functions …

Total answers: 5

Monitoring contents of files/directories?

Monitoring contents of files/directories? Question: I’m looking for a cross-platform file monitoring python package? I know it is possible to monitor files on windows using pywin32, and there are packages working on Linux/Unix but does anyone know about a cross-platform one? Asked By: dahpgjgamgan || Source Answers: I found this link, which talks about your …

Total answers: 5

Cross-platform way to get PIDs by process name in python

Cross-platform way to get PIDs by process name in python Question: Several processes with the same name are running on host. What is the cross-platform way to get PIDs of those processes by name using python or jython? I want something like pidof but in python. (I don’t have pidof anyway.) I can’t parse /proc …

Total answers: 9

Possible values from sys.platform?

Possible values from sys.platform? Question: What are the possible return values from the following command? import sys print sys.platform I know there is a lot of possibilities, so I’m mainly interested in the “main” ones (Windows, Linux, Mac OS) Asked By: dbr || Source Answers: Mac OS X (10.4, 10.5, 10.7, 10.8): darwin Linux (2.6 …

Total answers: 5

Cross platform keylogger

Cross platform keylogger Question: I’m looking for ways to watch mouse and keyboard events on Windows, Linux and Mac from Python. My application is a time tracker. I’m not looking into the event, I just record the time when it happens. If there are no events for a certain time, say 10 minutes, I assume …

Total answers: 3

Is there a cross-platform way of getting information from Python's OSError?

Is there a cross-platform way of getting information from Python's OSError? Question: On a simple directory creation operation for example, I can make an OSError like this: (Ubuntu Linux) >>> import os >>> os.mkdir(‘foo’) >>> os.mkdir(‘foo’) Traceback (most recent call last): File “<stdin>”, line 1, in <module> OSError: [Errno 17] File exists: ‘foo’ Now I …

Total answers: 1

How can I find the current OS in Python?

How can I find the current OS in Python? Question: As the title says, how can I find the current operating system in python? Asked By: UnkwnTech || Source Answers: https://docs.python.org/library/os.html To complement Greg’s post, if you’re on a posix system, which includes MacOS, Linux, Unix, etc. you can use os.uname() to get a better …

Total answers: 5

How do you run a Python script as a service in Windows?

How do you run a Python script as a service in Windows? Question: I am sketching the architecture for a set of programs that share various interrelated objects stored in a database. I want one of the programs to act as a service which provides a higher level interface for operations on these objects, and …

Total answers: 14