I need to cache some xml from a webservice to a local xml file for use by my web application.
There are two web services, one which returns the data, and one which returns the date/time the data last changed.
The xml file size could range from 50KB to 500KB
I currently have an executable that runs from a windows scheduler that perform...
I'd like to save my files using the primary key of the entry.
Here is my code:
def get_nzb_filename(instance, filename):
if not instance.pk:
instance.save() # Does not work.
name_slug = re.sub('[^a-zA-Z0-9]', '-', instance.name).strip('-').lower()
name_slug = re.sub('[-]+', '-', name_slug)
return u'files/%s_%s.n...
In python following statements do not work:
f = open("ftmp", "rw")
print >> f, "python"
I get the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 9] Bad file descriptor
But with the following code it works:
g = open("ftmp", "r+")
print >> g, "python"
Looks like I need to revise the...
I want to have an application writing out information at the same time that a monitor is reading it. The application is "embedded" (and on Win32 XP) and so has restricted memory and I/O functionality.
The simplest way I can think to do this is by writing the data to a buffer file from the application, and then read the same file using t...
I'd like to be able to show the progress of a file copy operation when copying files using Ruby (currently using FileUtils.cp) I've tried setting the verbose option to true but that just seems to show me the copy command issued.
I'm running this script from command line at the moment so ideally I'd like to be able to present something l...
I write unit tests to my code, using Moq as a mocking framework.
My code includes calls to the file system, using direct calls to System.IO classes. For instance, File.Exists(...) etc.
I'd like to change that code to be more testable, so I should have an interface, say IFile, with a relevant method, say Exists(string path).
I know I can ...
While reading a binary file using DJGPP on DOS this code hangs.
This happens when the fread call is made. If the call is removed then the program runs successfully.
The same code runs fine through Visual C++ 2008.
Has anyone experienced similar issues with djgpp ?
Am I missing out on something really simple ?
char x;
string Filena...
I'm running a very computationally intensive scientific job that spits out results every now and then. The job is basically to just simulate the same thing a whole bunch of times, so it's divided among several computers, which use different OSes. I'd like to direct the output from all these instances to the same file, since all the com...
I'm trying to get a line of integers from a text file and parse them into separate variables. The text file is set up like this:
ID:HP:MP:STR:WIS:SPD:GOLD:XP
0:100:50:10:5:12:5:10
I want to split them with the : symbol in between each. One of the problems I'm having with this is being able to read the file line by line as strings, par...
What is the simplest way to get the directory that a file is in? I'm using this to set a working directory.
string filename = "C:\MyDirectory\MyFile.bat"
In this example, I should get "C:\MyDirectory".
...
Hi
I need to Copy folder C:\FromFolder to C:\ToFolder
Below is code that will CUT my FromFolder and then will create my ToFolder.
So my FromFolder will be gone and all the items will be in the newly created folder called ToFolder
System.IO.Directory.Move(@"C:\FromFolder ", @"C:\ToFolder");
But i just want to Copy the files in FromFo...
How do you guys typically delete files on Linux OS? I am thinking of using the unlink function call, but I wonder if you have a better idea, as the C++ standard has no mention of file deletion operation and it is system dependent.
...
NSData *data;
data = [self fillInSomeStrangeBytes];
My question is now how I can write this data on the easiest way to an file.
(I've already an NSURL file://localhost/Users/Coding/Library/Application%20Support/App/file.strangebytes)
...
This question is from a decomposition of http://stackoverflow.com/questions/678471/what-are-good-programming-practices-to-prevent-malware-in-standalone-applications
The question has to do with malware dynamically getting into a program by infecting data files which the program reads/writes.
Is it safer to require data be stored in a...
Hi,
I'm trying to read from a text file to input data to my java program. However, eclipse continuosly gives me a Source not found error no matter where I put the file.
I've made an additional sources folder in the project directory, the file in question is in both it and the bin file for the project and it still can't find it.
I eve...
I have a comma delimited configuration file. The empty lines are ignored and there need to be errors on invalid lines:
foo,bar
foo2, bar3
I want to read this file into a HashMap where the key (foo) is mapped with a value (bar).
What is the best way to do this?
...
Is it possible to read/write data from/to a file in a PL/SQL block without using the UTL_FILE package in Oracle 10g?
I currently have a file containing a set of primary keys (approx. 28000) that I need query a table for additional data that needs to be written out to a file. The schema I am using is very restricted and do not have any c...
I am writing an Image Manager WPF application. I have a ListBox with the following ItemsTemplate:
<Grid x:Name="grid" Width="150" Height="150" Background="{x:Null}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="27.45"/>
</Grid.RowDefinitions>
...
My WPF application gets a file from the user with Microsoft.Win32.OpenFileDialog()...
Private Sub ButtonUpload_Click(...)
Dim FileOpenStream As Stream = Nothing
Dim FileBox As New Microsoft.Win32.OpenFileDialog()
FileBox.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
FileBox.Filter = ...
Dear All,
I'm working on a Python project that retrieves an image from MSSQL. My code is able to retrieve the images successfully but with a fixed size of 63KB. if the image is greater than that size, it just brings the first 63KB from the image!
The following is my code:
#!/usr/bin/python
import _mssql
mssql=_mssql.connect('<ServerIP...