FTP script won't transfer remote files to local computer
Before the mget command add a line that says
prompt
user422005
Updated on September 17, 2022Comments
-
user422005 over 1 year
I have a C library with several datatypes which I have wrapped with Python and ctypes - works very well! In C I have the following (schematic) code:
typedef struct type1_struct type1_t; typedef struct type2_struct type2_t; void some_function( type1_t *t1 , type2_t *t2) { if (t2 == NULL) { // Do whatever } else { // } }
The main point in this code is that some_function() can take NULL as value for the t2 argument. In Python the type1_t and type2_t types are wrapped with classes Type1 and Type2 using the from_param() method:
Class Type1: def from_param(self): return self.c_ptr def call_some_func(self , arg2 = None): # This fails when the python/ctypes tries to # lookup the from_param() method and arg2 is None. cfunc_some_function( self , arg2 ) lib_handle = ctypes.CDLL( lib ) cfunc_some_function = getattr( lib_handle , "some_function") cfunc_some_function.argtypes = [Type1 , Type2]
So the cfunc_some_function function is initialized to take a Type1 and Type2 instance as arguments, the ctypes layer will then call the from_param() methods of the two input arguments; however I would like the 'call_some_func()' method of the Type1 class to accept None for the arg2 argument, but then ctypes tries to call the from_param() method of the None object - which obviously fails.
So - I guess my question is: Is it possible to get the ctypes function call code to just pass NULL when it gets a None input argument?
Joakim
-
Richard over 14 yearsnow this goes thru all files on remote folder, but keeps saying "port command successful. no such file" ... all files are there though ... any ideas?
-
Richard over 14 yearssame results ... loops thru all the files in the folder, and keeps saying "no such file" but all the files are there ... i use the same credentials as i use for GUI ftp access, so permissions should not be the issue ... any ideas?
-
Richard over 14 yearsdidn't solve the issue but helped me get starter, thanx
-
Stewart Robinson over 14 yearsdid you fix why the files weren't coming down?
-
user422005 almost 13 yearsOK; that was interesting. I have ~ 15 cases of from_param() as a instance method, and that has worked nicely for me (except this instance is None problem). I did as you suggested and it worked nicely. Thanks!
-
Duncan almost 13 yearsI think it will work in most cases:
Type.method(obj)
andobj.method()
are interchangeable whenobj
is an instance ofType
, but ctypes can also callType.method(obj)
when obj is a different type such aNone
and that's what you've run into. -
Duncan almost 13 years@eryksun thanks: corrected. That's why I always write 'untested' when I can't test a code sample.