Problem: screenshots are being overwritten in each device's result html file
Scenario: I am running calabash-android to test a single mobile app running on multiple devices.
The SCREENSHOT_PATH environment variable is set as c:/AndroidApp/Results/deviceScreenshots/
This location will store all screenshots taken.
In a batch file an output format of html is specified and an output location of C:\AndroidApp\Results\device1\deviceId
For multiple devices we have a separate line per device, so device1, device2 etc.. etc..
When I finish the run and examine the screenshots for each device, I am seeing that screenshots are being overwritten and they are being taken from the environment variable location.
e.g: Environment variable folder has 10 screenshots
device 1 has taken 10 screen shots
device 2 has taken 10 screen shots
device 2 contains the same 10 screen shots as device one, due to the environment variable folder's imagenames being screenshot1.png, screenshot2.png etc etc
I have specified an unique device folder for each device html result output, so we do have unique result files, however the screenshots are being overwritten as being taken from the Environment variable folder.
any ideas? thanks all.
Graeme
Reading you question again I can see that you do set the path, but you use the same path for both runs? In case that is what you do and how you want to do it. My second option is probably most suitable for you(add a prefix to screenshots depending on device).
When you execute the test you can set screenshot path
SCREENSHOT_PATH=/tmp/foo/ calabash-android run
Link to Github about it https://github.com/calabash/calabash-android
So you could place screenshots in different folders.
Or you could add a prefix to the screenshots taken based on the device the test is run on. Like
screenshot({:prefix => "/tmp", :name=>"my.png"})
Link to Github https://github.com/calabash/calabash-android/blob/master/documentation/ruby_api.md
we tried a different approach by appending the screenshot name with a timeDate stamp instead of using an incremental integer counter.
added the following line of code to the operations.rb file. (not the failureHelpers.rb) to store the date in a specific format to the t1 variable, and output that t1 variable to the prefix.
##t1 = DateTime.now.strftime("%Y%m%dT%H%M%S%3N")
path = "#{prefix}#{name}_#{##t1}.png"
code snippet of operations.rb is now:
def screenshot(options={:prefix => nil, :name => nil})
prefix = options[:prefix] || ENV['SCREENSHOT_PATH'] || ""
name = options[:name]
if name.nil?
name = "screenshot"
else
if File.extname(name).downcase == ".png"
name = name.split(".png")[0]
end
end
##t1 = DateTime.now.strftime("%Y%m%dT%H%M%S%3N")
path = "#{prefix}#{name}_#{##t1}.png"
hope this helps, its not the solution to the original problem, just a re-thought out solution to the problem..phew...
anyway, thank you all for contributing , interesting puzzle indeed.
and thanks to my fellow tester here at work, was his work really not mine.
Related
I use the randomforest estimator, implemented in tensorflow, to predict if a text is english or not. I saved my model (A dataset with 2k samples and 2 class labels 0/1 (Not English/English)) using the following code (train_input_fn function return features and class labels):
model_path='test/'
TensorForestEstimator(params, model_dir='model/')
estimator.fit(input_fn=train_input_fn, max_steps=1)
After running the above code, the graph.pbtxt and checkpoints are saved in the model folder. Now I want to use it on Android. I have 2 problems:
As the first step, I need to freeze the graph and checkpoints to a .pb file to use it on Android. I tried freeze_graph (I used the code here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py). When I call the freeze_graph in my mode, I get the following error and the code cannot create the final .pb graph:
File "/Users/XXXXXXX/freeze_graph.py", line 105, in freeze_graph
_ = tf.import_graph_def(input_graph_def, name="")
File "/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/importer.py", line 258, in import_graph_def
op_def = op_dict[node.op]
KeyError: u'CountExtremelyRandomStats'
this is how I call freeze_graph:
def save_model_android():
checkpoint_state_name = "model.ckpt-1"
input_graph_name = "graph.pbtxt"
output_graph_name = "output_graph.pb"
checkpoint_path = os.path.join(model_path, checkpoint_state_name)
input_graph_path = os.path.join(model_path, input_graph_name)
input_saver_def_path = None
input_binary = False
output_node_names = "output"
restore_op_name = "save/restore_all"
filename_tensor_name = "save/Const:0"
output_graph_path = os.path.join(model_path, output_graph_name)
clear_devices = True
freeze_graph.freeze_graph(input_graph_path, input_saver_def_path,
input_binary, checkpoint_path,
output_node_names, restore_op_name,
filename_tensor_name, output_graph_path,
clear_devices, "")
I also tried the freezing on the iris dataset in "tf.contrib.learn.datasets.load_iris". I get the same error. So I believe it is not related to the dataset.
As a second step, I need to use the .pb file on the phone to predict a text. I found the camera demo example by google and it contains a lot of code. I wonder if there is a step by step tutorial how to use a Tensorflow model on Android by passing a feature vector and get the class label.
Thanks, in advance!
UPDATE
By using the recent version of tensorflow (0.12), the problem is solved. However, now, the problem is that what I should pass to output_node_names ??? How can I get what are the output nodes in the graph ?
Re (1) it looks like you are running freeze_graph on a build of tensorflow which does not have access to contrib ops. Maybe try explicitly importing tensorforest before calling freeze_graph?
Re (2) I don't know of a simpler example.
CountExtremelyRandomStats is one of TensorForest's custom ops, and exists in tensorflow/contrib. As was pointed out, TF switched to including contrib ops by default at some point. I don't think there's an easy way to include the contrib custom ops in the global registry in the previous releases, because TensorForest uses the method of building a .so file that is included as a data file which is loaded at runtime (a method that was the standard when TensorForest was created, but may not be any longer). So there are no easily-included python build rules that will properly link in the C++ custom ops. You can try including tensorflow/contrib/tensor_forest:ops_lib as a dep in your build rule, but I don't think it will work.
In any case, you can try installing the nightly build of tensorflow. The alternative includes modifying how tensorforest custom ops are built, which is pretty nasty.
I am working on an app in Delphi XE8.
When I run the program on my phone, it gives me an error:
Loading bitmap failed(image.png)
My code works as follows:
if ListBox1.ItemIndex = 0 then
begin
img.bitmap.LoadFromFile('Image.png');
iMin:= Round(iNumber * 1);
iMax:= Round(iNumber *13.24);
iAvg:= Round(iNumber * 2.59);
label7.Text:= inttostr(iMin);
label5.Text:= inttostr(iAvg);
label6.Text:= inttostr(iMax);
label2.Text:= 'Minimum';
label3.Text:= 'Average';
label4.Text:= 'Maximum';
end
else
...
Please note the image is saved in the same folder as my program.
Don't use relative paths. Always use absolute paths.
You need to use the Deployment Manager to deploy the image file to an appropriate folder on the phone, and then use the System.IOUtils.TPath class to locate that folder at runtime:
Standard RTL Path Functions across the Supported Target Platforms
On Android, deploy the image file to the ./assets/internal folder, and then use the TPath.GetDocumentsPath() method at runtime, as documented on this blog:
Deploying and accessing local files on iOS and Android
What the EDN documentation and blog both fail to mention is that you also need to add the System.StartupCopy unit to your app's uses clause.
uses
..., System.IOUtils, System.StartupCopy;
...
img.bitmap.LoadFromFile(TPath.Combine(TPath.GetDocumentsPath, 'Image.png'));
I developed a simple javafx application to be ported in Android Environment, however I cant type any characters in the TextField. I guess its a bug, how to fix this one?
Th problem on galaxy S5 android 5.0.1 is not present but on galaxy tab 4 android 5.0.2 it doesn't work i type but none is displyed.
Tried with normal textfield. And the problem persist also I have added the properties .
Another strange rhig is that the space where recognizer. And the del button . The text not
THe code by example is very easy
Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
double width = visualBounds.getWidth();
double height = visualBounds.getHeight();
TextField tt= new TextField();
tt.setTranslateY(-150);
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(tt);
borderpane.setCenter(stackPane);
Scene scene = new Scene(borderpane, width, height);
stage.setScene(scene);
Assuming that CustomTextField is just a custom TextField, this is a known issue, not related to the CustomTextField itself, given that it works in other device.
If you debug it:
./adb logcat -v threadtime
you surely find an exception that explains the issue: a StackOverFlow exception.
On older devices it can be solved adding this: create a java.custom.properties file, and include in it this property:
monocle.stackSize=128000
You may also include this one:
monocle.platform=Android
(it will be soon included by default in the next version)
Put the file at the root of your classpath, e.g. in the folder src/android/resources of your project.
Build and deploy the project on your mobile and check again.
I am writing an Android application to control a Nest thermostat. I was able to connect to it just fine and I can read the correct target temperature (turning the nob on the thermostat updates my TextView).
However, when I try to write the target temperature like this, nothing happens:
String thermostatID = mThermostat.getDeviceId();
mNest.thermostats.setTargetTemperatureF(thermostatID, 70);
I tried setting the HVAC mode first, in case I needed that, but this didn't work either:
String thermostatID = mThermostat.getDeviceId();
mNest.thermostats.setHVACMode(thermostatID, "cool");
mNest.thermostats.setTargetTemperatureF(thermostatID, 70);
The Textview flashes 70 for a brief second, but then shoots back up to 77 which is the target temperature that was set by the actual thermostat. Is this an issue with the SDK code for setTargetTemperatureF, or am I missing something simple here?
The permissions for the Nest thermostat are set on the Nest website. Visit https://developer.nest.com/products and sign in. You will be given a list of your products, all you need to do is select one and scroll down to permissions.
Note that after you change permissions, your mobile (or various platform) application will need to rerun authentication for this change to take place.
Try to modify your code as following, then you can set the target temperature.
mNest.setTargetTemperatureF(thermostatID, 70L, null);
I'm making an app in the Corona SDK that reads a .txt file from an SD card, presents the data in a cleaner form, then allows you to edit it.
Some example text:
#207 USER PREFERENCES Time Between Pressure Log Samples
207=15
#208 USER PREFERENCES Auto Print Each Pressure Log Sample
208=No
#209 USER PREFERENCES Auto Print Each Event Log Entry
209=No
#210 USER PREFERENCES Selective Range Printing
210=1
Basically I need to be able to take a specific line of text from a file, edit it, and put it back in place, with pure Lua. For example, I might want to change 208=No to 208=Yes without changing anything else in the file.
I've already searched this site, Google, and Corona's API page, but nothing seems to have what I'm looking for. Am I going to have to read all the file up to that line and after that line and concatenate it all?
Am I going to have to read all the file up to that line and after that line and concatenate it all?
You don't have to concatenate it. Just keep reading the file and storing lines until you reach the line you want to change. Make your change, read the entire rest of the file as one string, and then write all the previously read lines in order.
It would look something like this:
local hFile = io.open(..., "r") --Reading.
local lines = {}
local restOfFile
local lineCt = 1
for line in hFile:lines() do
if(lineCt == ...) then --Is this the line to modify?
lines[#lines + 1] = ModifyLine(line) --Change old line into new line.
restOfFile = hFile:read("*a")
break
else
lineCt = lineCt + 1
lines[#lines + 1] = line
end
end
hFile:close()
hFile = io.open(..., "w") --write the file.
for i, line in ipairs(lines) do
hFile:write(line, "\n")
end
hFile:write(restOfFile)
hFile:close()