flupke wrote: > I'm going to be distributing a program based on wxPython & python in a > few weeks time. The code will run on windows machines. > > Because i don't want the users to move the folders around or mess with > the program or taking copies home to fiddle with it, i was thinking of a > way to check when the program starts that it's still on the same > directory and same computer. > > That way i at least avoid unnecessary phone calls asking me for help > when they messed the program up. > > I'm thinking of a function that will generate such a code and put it in > a file. Then when the program starts it checks this file and checks the > code in there with a code that it generates at that time again based for > instance on the current directory and other components unique to that > computer. It could be a long string (but what info?) and then take a > hash from it and store the hash value. > > How could i construct such a code without being a total pain? For > instance i don't want to check for anything hardware related because > then my program would fail to work once the people change their hardware. > Anyway, it doesn't need to be waterproof. (not possible anyway) >
Your requirements are confusing -- you want the program to check "that it's still on the same ... computer" but you don't want it to fail if they change their hardware??? In short: don't bother. You will end up annoying people who have not "messed with" your software. Heuristics like "it's not on the same computer therefore it's been fiddled with" don't seem like a good idea. An app should not care where it is installed, so long as it can find its associated files and folders. If the app can't find them: Try putting out informative messages when something does go wrong, and write a copy to a dump-file (like the Dr Watson log file, but skip all the hexdump stuff). Put a timestamp and the computer name and the user's name and whatever else you can dig out of Windows in the dump-file. Then you can ask the user with a problem to e-mail you a copy of the dump-file. If (say) the computer name is "frodo" instead of "pathology03" then you can tell the user their usage is not supported. This is a good idea even with "normal" i.e. non-fiddling users, who can't remember what the error message said -- they've since killed the window or even re-booted their PC. Iy you tend towards paranoia, put a checksum somewhere in each message in case the devious fiends use Notepad to change "frodo" to "pathology03" :-) -- http://mail.python.org/mailman/listinfo/python-list