473,799 Members | 2,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File Creation Not Working In A Thread Class?

Hi All,

Thanks in advance for any and all help!

I have this code:

g = open(fileName, 'a')

where fileName is defined before the line it's used in. It works fine
when I use it outside a thread class.

When I put the same line in a thread class, it no longer works, and I get
an error:

IOError: [Errno 2] no such file u'fileName'

Are threads not allowed to create files?
Jun 27 '08
23 1683
bc90021 <py****@bc90021 .netwrites:
Hi All,

Thanks in advance for any and all help!

I have this code:

g = open(fileName, 'a')

where fileName is defined before the line it's used in. It works fine
when I use it outside a thread class.

When I put the same line in a thread class, it no longer works, and I get
an error:

IOError: [Errno 2] no such file u'fileName'
It's telling you that you haven't got a file called 'fileName'.
Posting the code that triggers this error would allow people to
diagnose the error accurately rather than guessing.

--
Arnaud
Jun 27 '08 #11
bc90021 wrote:
Hi All,

Thanks in advance for any and all help!

I have this code:

g = open(fileName, 'a')
I don't believe you. I think you have something like

g = open('fileName' , 'a')

instead of (as you claim)

g = open(fileName, 'a')

Do you see the difference?

Develop the skill of reading the error messages *very* carefully. Your error says there is no file named "fileName", and if you think about what's on your disk, I'll bet you won't find a file whose name is "fileName".
Gary Herron
where fileName is defined before the line it's used in. It works fine
when I use it outside a thread class.

When I put the same line in a thread class, it no longer works, and I get
an error:

IOError: [Errno 2] no such file u'fileName'

Are threads not allowed to create files?
--
http://mail.python.org/mailman/listinfo/python-list
Jun 27 '08 #12
7stud <bb**********@y ahoo.comwrote:
>* * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * tempfileName = "\"proctemp \\" +
self.matrix[c][0] + "_other.txt \""
It wouldn't exactly result in either of the error messages you posted, but
I expect the spurious quote marks round the filename will be giving you
problems.

Surely you want the filename to be something like 'proctemp\fred_ other.txt'
rather than '"proctemp\fred _other.txt"' with the spurious double quotes?
Jun 27 '08 #13
On May 11, 1:28*pm, bc90021 <pyt...@bc90021 .netwrote:
...and the exact error message was?
Here is a tip: if you want people to help you, then you have to help
them to help you. *Personally, I wouldn't respond to anymore of your
questions because you seem incapable of posting the information that was
requested.

So far, the people who have answered this post have gone on the
assumption that I'm stupid. *I'm not. *I took perfectly working code,
cut it from one class, and put it in another. *It stopped working in the
second class. *I've spent days on this and trust me, given what I've
experienced of the Python community so far, if I didn't have to ask, I
wouldn't.

(I really must say that so far the help I am getting in the Python
community is a big let down. *Whether it's on IRC or here, everyone has
an arrogance that I don't find anywhere else in the open source
community, and it seriously makes me question the choice of language that
I've made.)

The error message was at the top of the thread (am I incapable of posting
it, or are you incapable of following a thread?), but here it is again:

IOError: [Errno 2] no such file u'tempfileName'
Well, it appears to me that this error message is different than the
one in your first post. But maybe I'm on LSD right now and things
will be appear differently tomorrow.

In addition, I've never seen a python error message that doesn't
include the traceback, which you were asked to post, but apparently
are still incapbable of doing. Also, any line numbers in the error
message should be marked in your code with comments. That will help
other people help you, remember?

Jun 27 '08 #14
On May 11, 2:01*pm, 7stud <bbxx789_0...@y ahoo.comwrote:
On May 11, 1:28*pm, bc90021 <pyt...@bc90021 .netwrote:
...and the exact error message was?
Here is a tip: if you want people to help you, then you have to help
them to help you. *Personally, I wouldn't respond to anymore of your
questions because you seem incapable of posting the information that was
requested.
So far, the people who have answered this post have gone on the
assumption that I'm stupid. *I'm not. *I took perfectly working code,
cut it from one class, and put it in another. *It stopped working in the
second class. *I've spent days on this and trust me, given what I've
experienced of the Python community so far, if I didn't have to ask, I
wouldn't.
(I really must say that so far the help I am getting in the Python
community is a big let down. *Whether it's on IRC or here, everyone has
an arrogance that I don't find anywhere else in the open source
community, and it seriously makes me question the choice of language that
I've made.)
The error message was at the top of the thread (am I incapable of posting
it, or are you incapable of following a thread?), but here it is again:
IOError: [Errno 2] no such file u'tempfileName'

Well, it appears to me that this error message is different than the
one in your first post. *But maybe I'm on LSD right now and things
will be appear differently tomorrow.

In addition, I've never seen a python error message that doesn't
include the traceback, which you were asked to post, but apparently
are still incapbable of doing. *Also, any line numbers in the error
message should be marked in your code with comments. *That will help
other people help you, remember?
In addition, posting the exact output from this:
>print "We're in copying, and tempfileName is: %s...\n" % tempfileName
#The above line correctly prints the temporary file name every time!
The directory exists, too!
would be helpful.

In addition, reducing your code to a simple 10 line example that
produces the same problem and that anyone can run would be helpful.
You might find that making the effort to produce a simple 10 line
example that mimics the problem, will actually result in your solving
the problem yourself.
Jun 27 '08 #15
[CUT]
I have in no way assumed that you are stupid. I have tried to help you
formulate your problem better so that people on the list can help you.
I believe I have done so respectfully, with the aim of introducing you
to the modus operandi of this group.
I appreciate your help. However, the comments I got from other people
that "I'm sure you have quotes here..." type comments are incredibly
insulting. To tell someone that you're sure that they have quotes around
something when they don't is the height of arrogance and rudeness.
>(I really must say that so far the help I am getting in the Python
community is a big let down. Whether it's on IRC or here, everyone has
an arrogance that I don't find anywhere else in the open source
community, and it seriously makes me question the choice of language
that I've made.)

Don't judge too quickly. I think this newsgroup is on the whole
extremely helpful. I have learnt a lot from it. But you have to get
used to its ways, and until you are familiar with them, approach it with
humility.
Unfortunately, this is not my first interaction with the Python IRC
communities or Python newsgroups. I had tried working with this language
a while back (around 2000) and the answers I got were unhelpful and
usually rude. I decided to give it another shot for the program I'm
writing, and I'm regretting that. It's possible that I'm to blame - I'm
the common factor in both instances, but at the same time, when you ask a
question in #python and NO ONE ANSWERS at all, and they all just sit
there not talking at all, what's the point of having the IRC channel? If
newbies can't go there for help, what's the point? When there are 70
people in a channel, and no one even acknowledges your question has been
asked, where does one go for help? It's like talking to yourself.
>The error message was at the top of the thread (am I incapable of
posting it, or are you incapable of following a thread?), but here it
is again:

IOError: [Errno 2] no such file u'tempfileName'

This is different from the error message that you posted in your
original message.

Anyway, what is useful to us is a full traceback, no just an error
message.
It is not "different" except that I posted the full name the second
time. (tempfileName instead of the previously simplified fileName) The
code itself is actually irrelevant, in my humble opinion. In one place a
file creation line does not work; in the second place it does. How can
the same line of code do two different things in two places? Either it
creates a file or it doesn't. It should create the file in either place,
regardless of where it's being called.

Either way, I figured it out.
Jun 27 '08 #16
On Sun, 11 May 2008 19:55:31 +0000, Duncan Booth wrote:
7stud <bb**********@y ahoo.comwrote:

>Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* tempfileName = "\"proctemp \\"
Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* +
self.matrix[c][0] + "_other.txt \""

It wouldn't exactly result in either of the error messages you posted,
but I expect the spurious quote marks round the filename will be giving
you problems.

Surely you want the filename to be something like
'proctemp\fred_ other.txt' rather than '"proctemp\fred _other.txt"' with
the spurious double quotes?
Yup, that's what it was. I figured it out two seconds before this post.
However, it will be interesting to see how it handles files with spaces
in the name...

Thanks for your help!

Jun 27 '08 #17
bc90021 <py****@bc90021 .netwrites:

The error message was at the top of the thread (am I incapable of posting
it, or are you incapable of following a thread?), but here it is again:

IOError: [Errno 2] no such file u'tempfileName'
Typically, when you report an error message, it helps to paste the
whole traceback. For example, it may be that you are seeing an error
from an old version of the file that has quotes around tempfileName,
or the error is coming from somewhere else.

But to answer your original question: no, there are no problems with
threading and files, and this is just simple human mistake somewhere.
Jun 27 '08 #18
On May 11, 2:11*pm, bc90021 <pyt...@bc90021 .netwrote:
[CUT]
I have in no way assumed that you are stupid. *I have tried to help you
formulate your problem better so that people on the list can help you.
I believe I have done so respectfully, with the aim of introducing you
to the modus operandi of this group.

I appreciate your help. *However, the comments I got from other people
that "I'm sure you have quotes here..." type comments are incredibly
insulting. *To tell someone that you're sure that they have quotes around
something when they don't is the height of arrogance and rudeness.
The best way to get help is to post a simple example that demonstrates
your problem and that anyone can run and get the same error you are
getting. That means you need take your real code and you start
hacking out the bits that are irrelevant to the problem. With
judicious use of print statements you should be able to narrow the
problem down.

Your first post was about as far away from that as it could be. Your
first post was essentially equivalent to asking:
Why does this line:
>print name
>display "Jack" and not "Jill".
When you post a question like that, then you are either going to be
met with silence or people will attempt to debug your imaginary code
and guess at the problem, which sometimes works and sometimes
doesn't. If you find the guesses insulting, then post a better model
of your problem. The fact that you found these guesses insulting,
even though they were respectfully given and they were the obvious
answers in light of how little information you gave, means you are
probably going to have problems on any newsgroup you post to.

The python community has some real jerks in it, but you didn't meet
any of them in this thread.


(I really must say that so far the help I am getting in the Python
community is a big let down. *Whether it's on IRC or here, everyone has
an arrogance that I don't find anywhere else in the open source
community, and it seriously makes me question the choice of language
that I've made.)
Don't judge too quickly. *I think this newsgroup is on the whole
extremely helpful. *I have learnt a lot from it. *But you have to get
used to its ways, and until you are familiar with them, approach it with
humility.

Unfortunately, this is not my first interaction with the Python IRC
communities or Python newsgroups. *I had tried working with this language
a while back (around 2000) and the answers I got were unhelpful and
usually rude. *I decided to give it another shot for the program I'm
writing, and I'm regretting that. *It's possible that I'm to blame - I'm
the common factor in both instances, but at the same time, when you ask a
question in #python and NO ONE ANSWERS at all, and they all just sit
there not talking at all, what's the point of having the IRC channel? *If
newbies can't go there for help, what's the point? *When there are 70
people in a channel, and no one even acknowledges your question has been
asked, where does one go for help? *It's like talking to yourself.
The error message was at the top of the thread (am I incapable of
posting it, or are you incapable of following a thread?), but here it
is again:
IOError: [Errno 2] no such file u'tempfileName'
This is different from the error message that you posted in your
original message.
Anyway, what is useful to us is a full traceback, no just an error
message.

It is not "different" except that I posted the full name the second
time. *(tempfileName instead of the previously simplified fileName) *The
code itself is actually irrelevant, in my humble opinion. *In one place a
file creation line does not work; in the second place it does. *How can
the same line of code do two different things in two places? *Either it
creates a file or it doesn't. *It should create the file in either place,
regardless of where it's being called.

Either way, I figured it out.
Jun 27 '08 #19
bc90021 wrote:
>...and the exact error message was?

Here is a tip: if you want people to help you, then you have to help
them to help you. Personally, I wouldn't respond to anymore of your
questions because you seem incapable of posting the information that was
requested.

So far, the people who have answered this post have gone on the
assumption that I'm stupid. I'm not. I took perfectly working code,
cut it from one class, and put it in another. It stopped working in the
second class. I've spent days on this and trust me, given what I've
experienced of the Python community so far, if I didn't have to ask, I
wouldn't.

(I really must say that so far the help I am getting in the Python
community is a big let down. Whether it's on IRC or here, everyone has
an arrogance that I don't find anywhere else in the open source
community, and it seriously makes me question the choice of language that
I've made.)
Sorry, the arrogance is yours.

Expecting us to help with only partial information.

Expecting us to help when your posts of the error message changes
from one post to the next.

Expecting us to help when you refuse to post the traceback.

Expecting us to believe that it has anything to do with threads.
(No one believes that for a moment.)
While acknowledging that any piece of code may have bugs, Python's
threading included, the problem here looks to be some simple mistake in
the computation of the name of the file to be opened. Then I look at
the convoluted quoting surrounding your computation of the file name,
and my confidence in that as an explanation sky-rockets. Then someone
in another post has found an extra set of quotes embedded in your
filename you compute, and it's clear that we are on the right track.
The error message was at the top of the thread (am I incapable of posting
it, or are you incapable of following a thread?), but here it is again:

IOError: [Errno 2] no such file u'tempfileName'

--
http://mail.python.org/mailman/listinfo/python-list
Jun 27 '08 #20

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

Similar topics

9
11546
by: Eric | last post by:
Problem: -------- I'm trying to create an executable jar file. I can do so as long as I don't use the "package" statement in my source code. Once I put the package statement in I can't execute the jar file. Here is the criteria of what I am working with: ----------------------------------------------- Working directory: ------------------
5
2216
by: hpy_awad | last post by:
Can any body send to me a missing file to my compiler Turbo C++ ver 3,called tv.lib
8
26720
by: Gabe Moothart | last post by:
Hi, I'm writing a windows service which interacts with a separate process. Basically, it calls a process which creates a file, and then my service reads that file. The problem is, the external process can take a second or two to finish writing the file. If I try to read the file to soon, I get an exception that "The process cannot access the file because it is being used by another process". I could just set a timer, but the time it...
18
4355
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't get it to upload a file to the FTP server. I just get a "Cannot connect to remote server" error after this TRY: s = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
15
2837
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. Everything is the default settings I believe. IIS is running under Local System. In IIS the DefaultAppPool is running under Network Service. Annonymous access uses the account IUSR_JASMINE (machine name is Jasmine).
17
8032
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: I am trying to use the SaveFileDialog class to get a filename, which is subsequently opened for writing (write access, read sharing, but using read/write sharing doesn't make the problem go away anyway). Sometimes, on the statement where I...
3
4503
by: Sean C. | last post by:
Hey All, I'm having a little problem here. I have a project that I'm working on that involves a MySQL server database backend. I'm having no problem creating the database on the fly if it doesn't already exist and using it once it's created. My problem comes into play when I run the program for the first time. I'm wanting to have some kind of flag that lets me know that the database has not yet been created, so that I can call my...
9
3015
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
I want to open a text file and format it into a specific line and then apply color to a specific location of the text and then display it in a RichTextBox after all of this is done. I can do all of the above after the file is loaded into the RichTextBox, and I am trying to speed the process up by doing it in a temp file.
7
2834
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It seems to work fine, however I noticed that no web log entry is added when a successful download occurs (normally a 200 HTTP status code, however, if there is an authorization failure, it gets logged). I have a logging routine that logs a successful...
0
9538
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10473
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10249
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7563
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6804
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4138
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.