gcmd-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gcmd-dev] Python plugins


From: Piotr Eljasiak
Subject: Re: [gcmd-dev] Python plugins
Date: Mon, 11 Dec 2006 02:41:56 +0100

> Huh ?
> 
> Traceback (most recent call last):
>   File "sample-plugin.py", line 16, in main
>     f = file.open(fname,'rb')
> AttributeError: type object 'file' has no attribute 'open'

This is my mistake - please replace the offending line with:
    f = file(fname,'rb')
> 
> for:
> 
> #!/usr/bin/env python
>         
> try:
>        import gnomevfs
>        
> except ImportError:
>        import gnome.vfs as gnomevfs
>        
> import md5
>        
> 
> def main(main_wnd_xid, active_cwd, inactive_cwd,selected_files):
> 
>     for uri in selected_files:
>       fname = gnomevfs.get_file_info(uri).name
>         f = file.open(fname,'rb')
>         file_content = f.read()
>         f.close()
>         md5sum = md5.new(file_content).hexdigest()
>         print md5sum, fname
>     return True
> 
> 
> 
> ...how can i check if the import was successful ?

Import was successful, otherwise you'd get error message referring to
this line.

If you want to test  your script you can do it by hand using python
interpreter. In console run:

        python

and after getting '>>>' prompt you try

        >>> import gnomevfs
        >>> import md5
        >>> fname = 'myfile.txt'
        >>> f = file(fname,'rb')

and so on... 

Please note that we can't use uri-list explicitly (neither active_cwd
nor inactive_cwd) here, for it is not passed from elsewhere 


Piotr





reply via email to

[Prev in Thread] Current Thread [Next in Thread]