Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I was editing a .py file and I had saved it. The power cable was then pulled out of the pi, about 30 seconds after. When I restarted the pi, the file was still there, but the contents was empty (0 bytes). Is there a way to recover this file?
in linux if you used GEdit and you havent disabled the backup function, then there must be a hidden file with name similar to your file but with ~ appended to it. So if your file name is somefile.txt then look for somefile.txt~ in the same directory. This is the backup file and will give you your files state before last save.
also in linux this is a question like this that had been answered ! https://askubuntu.com/questions/50678/how-i-can-recover-a-previous-version-of-a-file
and for windows you can see this : https://superuser.com/questions/515906/is-there-any-way-to-restore-recover-a-file-that-was-saved-over-to-its-last-versi
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I am about to distribute an app, and I am creating an installer. I know that apps in windows go to C:\Program Files but I am also aware that the folder changes its name depending on the language, for example, in spanish it is C:\Archivos de Programa
This is quite tricky because I do not want to have to detect the language of windows and then having to create a different variable for each path in a different language. Is there any way I can get the name of that folder from python so I can just use that to create a single path?
Use the PROGRAMFILES environment variable:
>>> from os import environ
>>> environ['PROGRAMFILES']
'C:\Archivos de Programa'
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
If not, is there any function to flush the butter of fileIO?
Certainly this is possible from a technical point of view:
You need some sort of volume server for this. Typically used are either nfs or samba for such task, though many other options exist. You can use these to "export" the volume for usage by other systems. This also means, that you need to attach that "portable disk" (probably some sort of USB volume) to some local system where such software is installed and executed on.
However there is one issue here: the remote, importing (so mounting) system must be able to reach the exporting system on the network. So the exporting system must be visible on the network or even internet. This certainly is possible, but might require a little more effort if you do not have a static, routeable ip address for the exporting system. In such cases this is not really a good idea, since the reliability of the whole setup is questionable.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am using Windows 7.
I am trying make a file called PRN.csv. But get a "The specified device name is invalid" error.
I can make a file called PR.csv or PRN_.csv.
What is so special about PRN.csv?
N.B. I discovered the problem while using Pandas / Python to save a dataframe to csv. So it is relevant to this site. Apologies for not making it clear at the beginning.
This is a holdover from the DOS days. There are a number of special file names that are reserved, such as PRN (referring to the default printer), CON (the console), COM1–COM4, etc.
This is purely a backwards-compatible effort in the upper layers of the system, though. If you use the right APIs, you can create such a file because the file system doesn't care at all:
This was created in Far Manager which bypasses a few of such restrictions.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I asked a question about the fuser command yesterday here. It seems gedit (and other text editors, and perhaps even other processes) act a bit differently in the way they interact with files, so they don't show up on when calling fuser even though they have opened a file.
I would like to monitor a file for ANY process which accesses it, whether it keeps it open or not. Is there an alternative command / software which I might be able to use for this purpose please? This can include from languages such as python as well.
Thanks for reading.
If a file is not open then it's not being accessed. If what you want is to keep track of who opens what, then you need to setup an auditing tool like auditd.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
For example, if you have ever used git, when you do a commit it will open vi to add or edit some text, and when you exit it is able to intercept this and use that text. What is this called so I can lookup some docs on it? Any other information, especially performing this using python, would be very helpful.
Often, the user's $EDITOR environment variable is executed, and instructed to write a temporary file with some random name. The temporary file can then be read back in by your application and discarded when no longer needed.
# Your application makes a system call like:
$EDITOR /tmp/randfile1124098weasc9839x.txt
This allows the text editor to be a user preference. $EDITOR could be /usr/bin/vi, /usr/bin/emacs, whatever.
Here is how you can do this with Python:
import tempfile, os
f = tempfile.NamedTemporaryFile()
os.system("vi " + f.name) # this will open vi to edit your temporary file
text = f.read()
All you are doing is making a system call to a file in a temp directory. When the system call returns, read the file.