file-io

Running a metro app headlessly

三世轮回 提交于 2020-01-01 12:44:33
问题 I've hit a bit of a roadblock, and I'm hoping someone can help! I've written a metro application that serves as a unit test runner, and I now need to be able to call this application headlessly so that it can be used for validation in the build process. The way the metro app works is it runs a bunch of unit tests, generates an XML file that contains the test results, and displays the results to the user. Ideally, I would have a simple script that would run the metro app, execute the tests,

Preferred file line by line read idiom in Python

99封情书 提交于 2020-01-01 10:46:05
问题 I feel like almost every time I read a file in Python, what I want is: with open("filename") as file_handle: for line in file_handle: #do something Is this truly the preferred idiom? It mildly irritates me that this double indents all file reading logic. Is there a way to collapse this logic into one line or one layer? 回答1: For simple cases, yes, the two-level with and for is idiomatic. For cases where the indentation becomes a problem, here as anywhere else in Python, the idiomatic solution

Access files on a node slave from Jenkins master using Groovy

冷暖自知 提交于 2020-01-01 10:16:12
问题 I am using the Jenkins Build Flow plugin to achieve parallelization. The Groovy DSL does certain file operations. Even though the option Restrict where this project can be run is set to run the job on a specific slave, the DSL runs on master. This is not intended. Could someone tell me how I can restrict the DSL to run on the specified slave? Even if there is a way we can access the slave file system via the DSL, that should work. In general, how can we access files on a node slave from

Reading realtime output from airodump-ng

℡╲_俬逩灬. 提交于 2020-01-01 10:05:16
问题 When I execute the command airodump-ng mon0 >> output.txt , output.txt is empty. I need to be able to run airodump-ng mon0 and after about 5 seconds stop the command , than have access to its output. Any thoughts where I should begin to look? I was using bash. 回答1: Start the command as a background process, sleep 5 seconds, then kill the background process. You may need to redirect a different stream than STDOUT for capturing the output in a file. This thread mentions STDERR (which would be

Reading a comma-delimited text file line-by-line in Fortran

怎甘沉沦 提交于 2020-01-01 09:55:07
问题 I am a Fortran novice. I would like to be able to read a text file and save its contents in individual variables. I found a very helpful Fortran tutorial (http://www.math.hawaii.edu/~hile/fortran/fort7.htm#read), and I am trying to follow one of the examples listed there. Specifically, I made a text file called data.txt with the following text: 1.23, 4.56, 7.89 11, 13, "Sally" I have saved this text file in my current directory. Then, I have created a file test.f90 (also saving it in my

How to implement Concurrent read to a file mapped to memory in Java?

白昼怎懂夜的黑 提交于 2020-01-01 09:52:49
问题 I have many threads that concurrently read the same file(entirely about 100M), and only one thread to update the file. I want to map the file in memory to reduce FILE I/O. How can this be done in Java? I basically have considered the following 2 methods: with byte array to store the file, and each time create ByteArrayInputStream to read the buffer when multi-thread read. with NIO to get one file channel, synchronized the channel to read from the MappedByteBuffer for multi-thread read. I'm

How to implement Concurrent read to a file mapped to memory in Java?

Deadly 提交于 2020-01-01 09:51:25
问题 I have many threads that concurrently read the same file(entirely about 100M), and only one thread to update the file. I want to map the file in memory to reduce FILE I/O. How can this be done in Java? I basically have considered the following 2 methods: with byte array to store the file, and each time create ByteArrayInputStream to read the buffer when multi-thread read. with NIO to get one file channel, synchronized the channel to read from the MappedByteBuffer for multi-thread read. I'm

How to open a file for non-exclusive write access using .NET

时间秒杀一切 提交于 2020-01-01 09:35:32
问题 Is it possible to open a file in .NET with non exclusive write access? If so, how? My hope is to have two or more processes write to the same file at the same time. Edit: Here is the context of this question: I am writing a simple logging HTTPModule for IIS. Since applications running in different app pools run as distinct processes, I need a way to share the log file between processes. I could write a complex file locking routine, or a lazy writer, but this is a throw away project so its not

C# PCL Reading from File

只愿长相守 提交于 2020-01-01 08:43:12
问题 So I'm writing a portable class library that targets .NET 4.5, Windows 8 and Windows Phone 8. I'm trying to read from a text file that is part of the project as build content. I see that StreamReader is available in PCL's but I can't seem to find out how to get the stream from a file, given a file path. If anyone could point me to the right structures I'd appreciate it. Also if you could give direction for XML files, too. I'm only reading text files right now, but I'm going to be working in

Updating a properties file injected by Spring to include a last run timestamp

徘徊边缘 提交于 2020-01-01 07:05:36
问题 I have an application which makes used of a properties file loaded by Spring. The Properties instance is then injected into a few classes. The question is some of these properties are updated - for example we have a lastRun timestamp which we want to store here. Maybe there is a better way to go about storing something like this (suggestions welcome), but how can I go about updating the properties file? <util:properties id="props" location="some.properties"/> The props.store(...) method