error processing variables

Unknown frodo at fortress.site
Fri Sep 9 17:38:21 EDT 2005


PROBLEM: for some reason, the variables won't work outside the function.
I tried fix it by converting the variables to str and unicode and still no
joy.
         The only way it works is by typing each source and
         destination file by hand on the shutil.copy2() method.
         Or by specifying the functions *inside* the function itself.

Any ideas?

ERROR:
Traceback (most recent call last):
  File "data/scripts/wifi.py", line 76, in main
    toHPU()
  File "data/scripts/wifi.py", line 32, in toHPU
    s.copy2(toHPU,wlan)
  File "/usr/lib/python2.4/shutil.py", line 92, in copy2
    copyfile(src, dst)
  File "/usr/lib/python2.4/shutil.py", line 41, in copyfile
    if _samefile(src, dst):
  File "/usr/lib/python2.4/shutil.py", line 31, in _samefile
    return os.path.samefile(src, dst)
  File "/usr/lib/python2.4/posixpath.py", line 218, in samefile
    s1 = os.stat(f1)
TypeError: coercing to Unicode: need string or buffer, function found


CODE:

import shutil

#variables
s = shutil

toHPU = "/etc/sysconfig/network/toHPU.wifi"
wlan = "/etc/sysconfig/network/ifcfg-wlan-id-00:0e:38:88:ba:6d"
toAnyWifi = "/etc/sysconfig/network/toAny.wifi"
wired = "/etc/sysconfig/network/ifcfg-eth-id-00:0b:db:1b:e3:88"      


def toHPU():


    s.copy2(toHPU,wlan) 
    s.copy2(toAnyWifi,wired)
 
#end

#execute function
toHPU()

---------------





More information about the Python-list mailing list