This question already has answers here:
Monitoring contents of files/directories? [duplicate]
(5 answers)
Closed 10 years ago.
Could not find anything in python core to do this. Can anyone recommend a library or "battery" to do this? Ideally I would like this to be portable but it's OK if it is available only for Unix (my server).
On Linux, you could be interested in pyinotify
https://github.com/seb-m/pyinotify
Other related libraries:
http://people.gnome.org/~veillard/gamin/python.html
Python FAM interface: http://python-fam.sourceforge.net/
http://gorakhargosh.github.com/watchdog/
I don't think there's something portable for this kind of requirement.
That's too close to the OS IMO.
Otherwise for Linux, there's pynotify.
pyinotify is a binding for Linux inotify kernel filesystem notification subsystem.
Works quite well.
I was just looking for a python package that watches file modifications. Just stumbled upon pywatch and it might just be what you're looking for. It's very simple, but does what I need (fixing pyScss' lack of a watcher).
http://pypi.python.org/pypi/pywatch
Related
This question already has answers here:
Py2exe for Python 3.0
(5 answers)
Closed 9 years ago.
considering another stackoverflow question that was posted at 2009 and tools like py2exe that haven't been updated since 2008, is it possible ?
I am creating an application that saves and retrieves data from an sqlite db and I want to distribute it to my colleagues without having them to install python libraries and execute .py files. The application uses tkinter as a GUI library.
Is that possible in 2013 ?
Yes, it is possible.
You may want to use the tool called cx_Freeze, it creates an executable from a python3 application (including all the libraries it uses), and it does this cross-platform.
The only thing you need to know is that in order to create, let's say a windows executable, you must run cx_Freeze in windows. (same goes for MAC, linux, etc..)
You can read here about the usage of the script.
Good Luck!
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do I protect python code?
How do I hide my python code, I don't want the code to be available to everyone to see.
I know python is interpreted, but is there a way, tool .. etc to allow someone to use the software without being able to see the code?
You can reduce it to pyc files, but that's not really like full compilation. Python isn't really designed to be able to 'hide' code. The only way to fully hide implementation details that I know of is to deploy all your core logic on a server and expose it as services to your distributed app.
Maybe Pyrex might help you. It is a python to C compiler ; it is intended to let you make modules available to python. That way, you could choose what to hide from the user (as it would be in an opaque module) and what to show.
You could probably (after talking with some lawyers) plaster your code with license info (legally) preventing 3rd parties from using your code in ways that you don't want...but as other have said, if the user can run your code on their machines, they can "see" it (if they're determined enough at least) -- even if bundled in an exe or in pyc files...
Compile it and/or create an executable file with it?
http://www.py2exe.org/
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I make an EXE file from a Python program?
I have found several links talking about what to do, but I am unsure of how to use them. They often say to just use the code, but they don't say if I should put it in the terminal or use it to make a program to run. Many recommend the use of py2exe but when I try to use it it will not run because it says I do not have python 2.6 in my registery. I am rather new to the more complicated side of programming and any help would be appreciated. I am running windows vista.
This is certainly a duplicate question, but I'd recommend using py2exe. We probably need more information on how or why you are failing.
This question already has answers here:
How do I watch a file for changes?
(28 answers)
Closed 6 years ago.
I'm trying to use a method within a Python program to detect whether a file on the file system has been modified. I know that I could have something run on an every-5-seconds to check the last modification date off of the system, but I was curious as to whether there's an easier method for doing this, without needing to require my program to check repeatedly.
Does anyone know of such a method?
watchdog
Excellent cross platform library for watching directories.
From the website
Supported Platforms
Linux 2.6 (inotify)
Mac OS X (FSEvents, kqueue)
FreeBSD/BSD (kqueue)
Windows (ReadDirectoryChangesW with I/O completion ports; ReadDirectoryChangesW worker threads)
OS-independent (polling the disk for directory snapshots and comparing them periodically; slow and not recommended)
I've used it on a couple projects and it seems to work wonderfully.
For linux, there is pyinotify.
From the homepage:
Pyinotify is a Python module for
monitoring filesystems changes.
Pyinotify relies on a Linux Kernel
feature (merged in kernel 2.6.13)
called inotify. inotify is an
event-driven notifier, its
notifications are exported from kernel
space to user space through three
system calls. pyinotify binds these
system calls and provides an
implementation on top of them offering
a generic and abstract way to
manipulate those functionalities.
Thus it is obviously not cross-platform and relies on a new enough kernel version. However, as far as I can see, requiring kernel support would be true about any non-polling mechanism.
On windows there is:
watcher, which is a nice python port of the .NET FileSystemWatcher API.
Also there's (the one I wrote) dirwatch.
Both rely on the windows ReadDirectoryChangesW function. Though for real work, I'd use watcher (proper C extension, good API, python 2 & 3 support).
Mine is mostly an experiment calling the relevant APIs on windows, so it's only interesting if you want an example of calling these things from python.
You should also see inotifyx which is very similar to the previously mentioned pyinotify, but is said to have an API which changes less.
This question already has answers here:
How do I watch a file for changes?
(28 answers)
Closed 10 years ago.
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?
I'm working on an MIT-licensed library that helps Python
programs monitor file system events as portably as possible.
There are differences that I'm trying to iron out. Highly
alpha version at the moment:
Check it out here:
http://github.com/gorakhargosh/watchdog/
Patches and contributions are welcome.
For Unix/Linux based systems, you should use File Alteration Monitor Python bindings to libfam.
For Windows based systems, you should tie into the Win32 API FindFirstChangeNotification and related functions.
As for a cross platform way, I don't know about a good cross platform way. I think it would be best to build a module yourself that works on either OS that uses one of the 2 above methods after detecting what OS it is.
Also check out this option:
http://pypi.python.org/pypi/watchdog
Was used with a cross-platform app on Windows and OS X.
I found this link, which talks about your problem. Although it doesn't really provide s solution/library, I think it will help.
http://www.stepthreeprofit.com/2008/06/cross-platform-monitoring-of-filesystem.html
I don't think there is a cross-platform one yet, so you might want to roll your own.
I am inexperienced in this area so I am not really sure. I hope this helps.
Note
I stand corrected, gamin is available on cygwin as Adam Bernier pointed out to me in a comment. You may want to research other options on cygwin (if they exist).
The easiest way on Linux is to use inotifywait (given that your kernel is recent enough). You don't need any special bindings, inotifywait can be customized to print output lines on standard output in any way you want. Look and this question for a good example.