Accessing file that has been opened by another program

This is the place for queries that don't fit in any of the other categories.

Accessing file that has been opened by another program

Postby jorma » Tue Jul 30, 2013 9:37 pm

Hi

I'm planning to create a Python script that will constantly read game log and report if anything interesting happens. The script opens and scans the log file every second. However, it seems that while the script is running the game can not write anything to the log. Is there a solution for this?

I'm working in the Windows environment.
jorma
 
Posts: 2
Joined: Tue Jul 30, 2013 9:34 pm

Re: Accessing file that has been opened by another program

Postby Yoriz » Tue Jul 30, 2013 10:02 pm

Hi,
welcome to the forum.
please read the new user link in my signature.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Image
User avatar
Yoriz
 
Posts: 1045
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Accessing file that has been opened by another program

Postby jorma » Wed Jul 31, 2013 10:13 am

Actually it seems that the game is able to write log but while it's writing it my Python script is unable to open the file.

I tried to use buffering and I also tried to first make a temp copy of the log before reading it. However, Python is not able to open and read the log file untill the game is closed.
jorma
 
Posts: 2
Joined: Tue Jul 30, 2013 9:34 pm

Re: Accessing file that has been opened by another program

Postby micseydel » Wed Jul 31, 2013 9:40 pm

That means that the game is locking the file. There isn't really anything you can do about that, as far as I know.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1441
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 2 guests