Python Libraries for FTP Upload/Download? - python

Okay so a bit of forward:
We have a service/daemon written in python that monitors remote ftp sites. These sites are not under our command, some of them we do NOT have del/rename/write access, some also are running extremely old ftp software. Such that certain commands do not work. There is no standardization among any of these ftp's, and they are out of our control(government).
About a year ago i wrote a ftp wrapper library for in house that basically adds in stuff like resume upload/resume download/verifying files are not currently being written to, etc. The problem is we soon found out is that due to so many of the ftp servers running werid/non standard software we were constantly fighting with the wrapper library/ftplib.
Basically I've given up on ftplib. Is there an alternative? I've looked at most of the ftp alternatives all of them are missing one or another key component of functionality.
What ever the choice is, it must run for python 2.5.2 (we cannot change). and must run on Linux/Windows/HP-UX.
Update:
Sorry i forgot to tell you alternatives i looked at:
ftputil, problem is it does not support resume upload/download and stuff like partially downloading files given an offset.
Pycurl looked good, i'll look at it again.

You don't mention which alternatives you've looked at already. Is ftputil one of them?
http://ftputil.sschwarzer.net/trac/wiki/Documentation
If you're trying to code around edge cases from various server implementations, you might be better off looking at the code used by Mozilla/Firefox. I imagine this is one of the things they have to deal with constantly.

You may have better luck with one of the cURL bindings such as pycURL.

Related

How to resync time automatically with python on a windows server?

Ive been looking the net dry to find a solution to this and i hope you can help me.
The main goal is that i have my client which interacts with Bybit API servers, their servers has a strict time window offset that i need to be in the bounds of and to do it so, i choose the method of resyncing my time since that worked, but more options might be available for this so feel free to let me know if you got other suggestions.
What i am looking for, is a way for me to tell the python script to resync my time.
It Could be something like w32tm /resync, however all that ive found out after alot of testing is that any deployed script even adminstrator shell commands can not execute w32tm commands unless a typed password is used, and even trying with a typing emulator to automaticly fake the typing, that didnt work.
So is there another way for me to force a /resync of time?
Im looking forward to hearing your answers and hopefully you can stear me in the right direction.
Best regards.
Mathias.
Easier install NPT software o the machines and it runs a service.
These are accurate.
As suggested you let one machine in the network sync time from Meinberg and the rest of the network gets their time form the NTP Server.
https://www.meinbergglobal.com/english/sw/ntp.htm

Where do messages go when using pythoncom.PumpMessages()?

I would like to know where does the function pythoncom.PumpMessage() stores the message when it comes into play. I was going through a site and just saw a Python Script for Key logger, I copied the code and used it on my computer but I don't feel safe, after deleting that code I think it's still running in the background and copying my keypresses. Is it so, please help.
If the python script was sending messages to anyone, you'd probably be able to tell by looking at the code. Somewhere there would be a block of code sending some file to a server.
As for PumpMessages(), it
Pumps all messages for the current thread until a WM_QUIT message.
According to this documentation. You can find other answered questions on this with a Google search as well. Pythoncom isn't sending any information to an external source in and of itself, however your script might be. You'd have to check your code for a block doing that.
As for it running after you delete the script, highly unlikely. If you didn't manually or programmatically (in the script) attach the Python script to some daemon, it isn't manifesting itself anywhere. You may be over-estimating the power of a basic Python keylogger. I wouldn't worry.
I've tried keyloggers before with pythoncom, and I've never had a problem. You can also look in the pythoncom library to find the PumpMessages() function and see if that is sending anything.

auto detect file in a folder

Sorry wasn't sure how to best word this question.
My scenario is that I have some python code (on a linux machine) that uses an xml file to acquire its arguements to perform a task, on completion of the task it disposes of the xml file and waits for another xml file to arrive to do it all over again.
I'm trying to find out the best way to be alerted an xml file has arrived in a specified folder.
On way would be to continually monitor the folder in the Python code, but that would mean a lot of excess resourses used while waiting for something to turn up (which may be as little as a few times a day). Another way, would be to set up a cronjob, but it's efficiency would't be any better than monitoring from within the code. An option I was hoping was possible would be to set up some sort of interrupt that would alert the code when an xml file appeared.
Any thoughts?
Thanks.
If you're looking for something "easy" to just run a specific script when new files arrive, the incron daemon provides a very handy combination of inotify(7) and cron(8)-like support for executing programs on demand.
If you want something a little better integrated into your application, or if you can't afford the constant fork(2) and execve(2) of the incron approach, then you should probably use the inotify(7) interface directly in your script. The pyinotify module can integrate with the underlying inotify(7) interfaces.

Make new software for Windows 95 on 486 machines, what to use?

I have a VB6 application running on a number of old 486 Windows 95 machines and sometimes the application is upgraded. The only way to accomplish this today is to use Hyperterminal and send the file over a null modem cable. Replacing the machines is not an option at this point.
I want to write an application that can take care of transferring the updating app over null modem without rewriting the VB6 app. This means I'm free to use anything I see fit. What alternatives are there?
These are the ones I can think of but I'd like to know if I'm wrong and any pros/cons. Also, I'd prefer to avoid C/C++ if at all possible.
Python with py2exe
Another VB6 app
C/C++
Edit: Some clarifications after reading the comments:
I want to make the process as easy as possible, today we have to remove and dismantle the computer, connect a keyboard and then fire up Hyperterminal to get going. That's why I want something more automatic. I'm open to suggestion of existing solutions but given the specific needs I didn't think there were any.
There is no ethernet on some of the computers either so the solution needs to be able to run RS232.
And again: Replacing the machines is not an option at this point. Just trust me on this.
If you must use a null modem, how about the built in serial line networking support?
Then you can just use normal network methods (psexec, file share, etc) methods to do the update.
Network Method
I would first get network cards installed in everything. If you want something that you can just plugin and go, look for any card compatible with NE2000. That card will work out of the box on Windows 3.11 and 95, no problem. In particular, you can find the 3Com EtherLink II or the 3C509B for very cheap online. It's an excellent card. (The Google Shopping results list several for under $20.)
From there, just enable the Windows File/Print Sharing service over TCP/IP, and you're good to go! After you've done this, you can remotely manage and upgrade these machines, saving you a lot of headache later on.
Serial-Port Method
Deanna's suggestion of using the serial port as a network device and transferring files normally will work as well. However, there is a bit of setup involved, and it can be a hassle if you've never done it. There are several other software options. I recommend LapLink. It's fairly painless.
You could even go all-out and pickup a multi-port serial interface for fairly cheap these days, and manage these computers centrally. RS232 is very robust and can go a long distance over the proper cabling.
Networking over Ethernet is the way to go though. If at all possible, choose that option.
We've got a few testing laboratories in a similar situation-the labs make money for the company so no touching the ancient computers that run the tests under pain of death. :-)
Anyway, pySerial seems like it'd work for this application, maybe take a look at their wxPython examples for some ideas on a GUI.
I guess the answer is pretty simple if you are happy using VB6 and the other app is already VB6, then use it.
That will do whatever serial comms you require quite adequately. Remember though you may want to update the application you write to do the updating in which case you are back to using hyperterminal!

python IPC (Inter Process Communication) for Vista UAC (User Access Control)

I am writing a Filemanager in (wx)python - a lot already works. When copying files there is already a progress dialog, overwrite handling etc.
Now in Vista when the user wants to copy a file to certain directories (eg %Program Files%) the application/script needs elevation, which cannot be asked for at runtime. So i have to start another app/script elevated, which does the work, but needs to communicate with the main app, so latter can update the progress etc.
I searched and found a lot of articles saying shared memory and pipes are the easiest way. So what i am looking for is a 'high level' platform independent ipc library whith python bindings using shared mem or pipes.
I already found ominORB, fnorb, etc. They look very interesting, but use TCP/IP, is there an equivalent lib using shared mem or pipes ? Since the ipc-client is always on the same machine sockets seems not to be neccesary here. And i am also afraid the user would have to allow ipc-socket-communications on his/her personal firewall.
EDIT: I really mean high level: it would be great to be able to just call some functions like when using omniORB instead of sending strings to stdin/stdout.
How about just communicating with the second process using stdin/stdout?
There are some caveats due to input and output buffering, but take a look at this Python Cookbook recipe, and also Pexpect, for ideas on how to do this.

Categories