473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

error processing variables

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()

---------------
Sep 9 '05 #1
1 1765
> 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()


Your problem is that the def statement reassignes the name "toHPU" to a
function instead of a string. So when the code runs, you're passing a
function object to s.copy2.

Sep 9 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Guy Robinson | last post by:
I have the code below which parses an expression string and creates tokens. Can anyone suggest the best of error checking for things like: Valid variable only obj.attribute -whitespace allowed...
0
by: Yarco | last post by:
I have just installed phpdocumentor on using: pear.bat install phpdocumentor-beta to suitable my php version. Then i create a test file "test.php" to have a trial. But the result is:...
3
by: Girish | last post by:
so I was looking at an example on codeproject.com that talked about how to globalize your error handling. I was extremely confused by some code. Id appreciate if someone could help me out by...
6
by: chokk | last post by:
All, I am getting the following error when I try to run a form page. Can someone tell me what this is about and show me how to fix it. Thnaks. Server Error in '/' Application...
1
by: whitehorse | last post by:
When the warehousecontroller service is invoked, the following error message is sent to the application log: Event Type: Error Event Source: TFS Warehouse Event Category: None Event ID: 3000...
11
by: Frankie | last post by:
Hello: New user here...first post to group. I'm getting an SQL syntax error when I try to run the following query: $query = sprintf("SELECT itemNumber, entryDate, modifyDate, thumbnailURL,...
4
by: andrewcw | last post by:
I am moving some code forward from .NET 1.1. I was able to load the XSL file and perform the transform. The MSDN documentation looks like it should be easy. But I get a compile error. Ideas ?...
13
by: Albert | last post by:
Hi I'm using the lcc compiler for win32. I tried compiling a program but there's an error stating: "cpp: Can't open input file clrscr()" I don't get it - I've included <tcconio.h>. (strange why...
4
by: Chronictank | last post by:
Hi, as a bit of background (and seeing as it is my first post :)) i am a complete newbie at perl. I literally picked it up a week ago to do this project as it seemed like the best choice for a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.