flick 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +127 -0
- data/Rakefile +1 -0
- data/bin/console +15 -0
- data/bin/flick +87 -0
- data/bin/setup +7 -0
- data/flick.gemspec +37 -0
- data/lib/flick.rb +16 -0
- data/lib/flick/android.rb +114 -0
- data/lib/flick/checker.rb +35 -0
- data/lib/flick/info.rb +33 -0
- data/lib/flick/ios.rb +74 -0
- data/lib/flick/log.rb +42 -0
- data/lib/flick/screenshot.rb +29 -0
- data/lib/flick/simple_daemon.rb +128 -0
- data/lib/flick/system.rb +30 -0
- data/lib/flick/version.rb +3 -0
- data/lib/flick/video.rb +158 -0
- metadata +227 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e81859ea546a01df31102f29fc4657df27c46fe0
|
4
|
+
data.tar.gz: 9f1a43b57c5337fe732b01bdabec233a4cf0040c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5da1d5231a633095d3fe7cda6452d007d7c13e78f17ddee6939bc6427f1135909a544649a83285850f71cd06de4a43b7ade43c10bd463e493a9dad4cf7e14f8b
|
7
|
+
data.tar.gz: 83780db9a51eb5ab0b50a0e812138e95082389ed5ddf197cc22bf000d62ed9575dc869bec50ebfbc11160640395cd68f72f0f25e04b1beca4ac87f5a6470072d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Justin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# FLICK
|
2
|
+
A CLI to capture screenshots, video, logs, and device information for Android (Devices & Emulators) and iOS (Devices).
|
3
|
+
|
4
|
+
<img src="https://www.dropbox.com/s/o49et3fhncu3l4v/animacii_09.gif?raw=1" width="600">
|
5
|
+
|
6
|
+
Features
|
7
|
+
--------
|
8
|
+
|
9
|
+
* Easily capture screenshots for Android and iOS.
|
10
|
+
* Video record real android devices. (OS > 4.4)
|
11
|
+
* Extend recording past the 180 seconds SDK limit.
|
12
|
+
* Save video formats in mp4 or gif.
|
13
|
+
* Flick auto detects if a device is recordable.
|
14
|
+
* Falls back to screenshot recording if video record is not available.
|
15
|
+
* Video record android emulators and **real** iOS devices.
|
16
|
+
* Takes a screenshot every 0.5 seconds (default), then combines the screenshots into a single mp4 or gif.
|
17
|
+
* iOS example [here](https://www.dropbox.com/s/4pjhhmnsx9gj5pi/ios-flick-example.mp4?dl=0)
|
18
|
+
* Android Emulator example [here](https://www.dropbox.com/s/gwunrvgzxkny13z/android-flick-example.mp4?dl=0)
|
19
|
+
* Flick auto selects device when only one device is connected, per platform.
|
20
|
+
* Save log output for Android or iOS.
|
21
|
+
* Display device information or save it to a file.
|
22
|
+
|
23
|
+
Reason
|
24
|
+
------
|
25
|
+
I wanted an easy way to video record my automation tests for mobile, and I didn't need the video quality to be perfect. Unfortunately, you cannot video record on android emulators, but you can take screenshots! You also cannot video record iOS without using QuickTime, or doing what [this](https://github.com/appium/screen_recording) did, but it's not maintained anymore.
|
26
|
+
|
27
|
+
So I created Flick to work for my needs, and included a couple other tools I use frequently. Hopefully this will be as helpful for others too. It's also a CLI and language-agnostic, it can be used with any framework where you can make a system call. See examples [here](https://github.com/isonic1/appium-mobile-grid/blob/flick/ios/spec/spec_helper.rb#L15-L16) and [here](https://github.com/isonic1/appium-mobile-grid/blob/flick/android/spec/spec_helper.rb#L22-L23). I suppose there are use cases for this outside of test automation. I'd love to hear them if so.
|
28
|
+
|
29
|
+
If you're looking for high-quality video, then this wouldn't be the tool for you. Take a look at this great tool [androidtool-mac](https://github.com/mortenjust/androidtool-mac) instead.
|
30
|
+
|
31
|
+
Prerequisites
|
32
|
+
-------------
|
33
|
+
#### System Tools
|
34
|
+
* Install ffmpeg. [OSX](https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX)
|
35
|
+
* ```$ brew install ffmpeg```
|
36
|
+
* Install mp4box. [OSX](http://hunterford.me/compiling-mp4box-on-mac-os-x/)
|
37
|
+
* ```$ brew install mp4box```
|
38
|
+
|
39
|
+
#### Android
|
40
|
+
* Install [SDK Tools](http://developer.android.com/sdk/installing/index.html?pkg=tools).
|
41
|
+
* SDK tools are added to your $PATH. [OSX](http://stackoverflow.com/questions/5526470/trying-to-add-adb-to-path-variable-osx)
|
42
|
+
* Enable [USB Debugging](https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm) on your device(s).
|
43
|
+
* Emulator or Devices have approximately 1GB of [sdcard space](http://developer.android.com/tools/help/mksdcard.html).
|
44
|
+
|
45
|
+
#### iOS
|
46
|
+
* Install [Xcode](https://developer.apple.com/xcode/download/).
|
47
|
+
* Install Xcode [Command Line Tools](http://railsapps.github.io/xcode-command-line-tools.html).
|
48
|
+
* Enable [Developer Mode](http://apple.stackexchange.com/questions/159196/enable-developer-inside-the-settings-app-on-ios) on iPhone or iPad devices.
|
49
|
+
* Install [libimobiledevice](http://www.libimobiledevice.org/).
|
50
|
+
* ```$ brew install libimobiledevice```
|
51
|
+
|
52
|
+
Installation
|
53
|
+
------------
|
54
|
+
|
55
|
+
$ gem install flick
|
56
|
+
|
57
|
+
|
58
|
+
Usage:
|
59
|
+
------
|
60
|
+
$ flick --help
|
61
|
+
|
62
|
+
DESCRIPTION:
|
63
|
+
|
64
|
+
A CLI to capture screenshots, video, logs, and device info for Android (Devices & Emulators) and iOS (Devices).
|
65
|
+
|
66
|
+
COMMANDS:
|
67
|
+
|
68
|
+
help Display global or [command] help documentation
|
69
|
+
info Get device information
|
70
|
+
log Get device log output
|
71
|
+
screenshot Take a screenshot
|
72
|
+
video Record video
|
73
|
+
|
74
|
+
GLOBAL OPTIONS:
|
75
|
+
|
76
|
+
-h, --help
|
77
|
+
Display help documentation
|
78
|
+
|
79
|
+
-v, --version
|
80
|
+
Display version information
|
81
|
+
|
82
|
+
-t, --trace
|
83
|
+
Display backtrace when an error occurs
|
84
|
+
|
85
|
+
* See usage examples in:
|
86
|
+
|
87
|
+
`$ flick info --help`
|
88
|
+
|
89
|
+
$ flick info -p (ios or android)
|
90
|
+
$ flick info -p (ios or android) -s true -o $HOME
|
91
|
+
|
92
|
+
|
93
|
+
`$ flick log --help`
|
94
|
+
|
95
|
+
$ flick log -a start -p (ios or android) -o $HOME -n iosLog
|
96
|
+
$ flick log -a stop -p (ios or android)
|
97
|
+
|
98
|
+
`$ flick screenshot --help`
|
99
|
+
|
100
|
+
$ flick screenshot -p (ios or android)
|
101
|
+
|
102
|
+
`$ flick video --help`
|
103
|
+
|
104
|
+
$ flick video -a start -p (ios or android)
|
105
|
+
$ flick video -a stop -p (ios or android) -o /output -n myVideo -f gif
|
106
|
+
$ flick video -a start -p android -u emulator-5554 -c 1000
|
107
|
+
$ flick video -a stop -p android -u emulator-5554
|
108
|
+
|
109
|
+
Demo
|
110
|
+
----
|
111
|
+
<img src="https://www.dropbox.com/s/9be37gc1c2dlxa6/flick-demo.gif?raw=1" width="600">
|
112
|
+
|
113
|
+
## Contributing
|
114
|
+
|
115
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/isonic1/flick. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
116
|
+
|
117
|
+
## TODO
|
118
|
+
* Dry the code a bit.
|
119
|
+
* Setup Flick android for cross platform os's (windows & linux)
|
120
|
+
* Add screenshot capture for iOS Simulators.
|
121
|
+
* Multithread the screenshot and pull process.
|
122
|
+
* Look into capturing video from iOS similar to [this](https://github.com/mortenjust/androidtool-mac/blob/9347cd9aeca9e7370e323d12f862bc5d8beacc25/AndroidTool/IOSDeviceHelper.swift#L56)
|
123
|
+
|
124
|
+
## License
|
125
|
+
|
126
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
127
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "flick"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
require 'json'
|
15
|
+
IRB.start
|
data/bin/flick
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require_relative '../lib/flick'
|
3
|
+
require 'commander/import'
|
4
|
+
|
5
|
+
program :version, '0.0.1'
|
6
|
+
program :description, 'A CLI to capture screenshots, video, logs, and device info for Android (Devices & Emulators) and iOS (Devices).'
|
7
|
+
|
8
|
+
command :video do |c|
|
9
|
+
c.syntax = 'flick video [options]'
|
10
|
+
c.description = 'Record video'
|
11
|
+
c.example 'description', "flick video -a start -p android -e true -u TA64300B9C\n flick video -a stop -p android -n my-video -o /mydir"
|
12
|
+
c.option '-a', '--action ACTION', String, 'Set action: start or stop'
|
13
|
+
c.option '-p', '--platform PLATFORM', String, 'Set platform: android or ios'
|
14
|
+
c.option '-u', '--udid UDID', String, 'Set device UDID. Defaults to only connected device per platform'
|
15
|
+
c.option '-s', '--seconds SECONDS', String, 'Set the seconds per screenshot. Default: 0.5'
|
16
|
+
c.option '-c', '--count COUNT', Integer, 'Set maximum number of screenshots. Default: 500'
|
17
|
+
c.option '-e', '--extend EXTEND', 'Extend android video past 180 seconds SDK limit. (REAL devices only - OS > 4.4). Default: false'
|
18
|
+
#The options below are relavent to the stop action...
|
19
|
+
c.option '-n', '--name NAME', String, 'Set name of output file, Default: UDID'
|
20
|
+
c.option '-q', '--unique UNIQUE', 'Pull only unique screenshots. Significantly speeds up the pulling process. Default: true'
|
21
|
+
c.option '-f', '--format FORMAT', String, 'Set output format (mp4 or gif). Default: mp4'
|
22
|
+
c.option '-o', '--outdir OUTDIR', String, "Set output directory. Default is #{Dir.pwd}"
|
23
|
+
c.action do |args, options|
|
24
|
+
options.default \
|
25
|
+
:seconds => 0.5, #Seconds per screenshot.
|
26
|
+
:count => 500, #This is a safety check to stop runaway screenshot process.
|
27
|
+
:extend => false, #Extend android video recording (for REAL devices and os >= 4.4) past 180 seconds.
|
28
|
+
:unique => true, #defaults to pulling only unique screenshots. Speeds up pulling process from device.
|
29
|
+
:format => "mp4",
|
30
|
+
:outdir => Dir.pwd #defaults to save in current directory.
|
31
|
+
|
32
|
+
Video.new(options.default).run
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
command :screenshot do |c|
|
37
|
+
c.syntax = 'flick screenshot [options]'
|
38
|
+
c.summary = 'Take a screenshot'
|
39
|
+
c.description = c.summary
|
40
|
+
c.example 'description', 'flick screenshot -p ios'
|
41
|
+
c.option '-p', '--platform PLATFORM', String, 'Set platform: android or ios'
|
42
|
+
c.option '-u', '--udid UDID', String, 'Set device UDID.'
|
43
|
+
c.option '-n', '--name NAME', String, "Set name of output file. Default: UDID"
|
44
|
+
c.option '-o', '--outdir OUTDIR', String, "Set output directory. Default is #{Dir.pwd}"
|
45
|
+
c.action do |args, options|
|
46
|
+
options.default \
|
47
|
+
:outdir => Dir.pwd #defaults to save in current directory.
|
48
|
+
|
49
|
+
Screenshot.new(options.default).screenshot
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
command :log do |c|
|
54
|
+
c.syntax = 'flick log [options]'
|
55
|
+
c.summary = 'Get device log output'
|
56
|
+
c.description = c.summary
|
57
|
+
c.example 'description', "flick log -a start -p ios -o /logs -n myLog\n flick log -a stop -p ios"
|
58
|
+
c.option '-a', '--action ACTION', String, 'Set action: start or stop'
|
59
|
+
c.option '-p', '--platform PLATFORM', String, 'Set platform: android or ios'
|
60
|
+
c.option '-u', '--udid UDID', String, 'Set device UDID.'
|
61
|
+
c.option '-n', '--name NAME', String, "Set name of output file. Default: UDID"
|
62
|
+
c.option '-o', '--outdir OUTDIR', String, "Set output directory. Default is #{Dir.pwd}"
|
63
|
+
c.action do |args, options|
|
64
|
+
options.default \
|
65
|
+
:outdir => Dir.pwd #defaults to save in current directory.
|
66
|
+
|
67
|
+
Log.new(options.default).run
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
command :info do |c|
|
72
|
+
c.syntax = 'flick info [options]'
|
73
|
+
c.summary = 'Get device information'
|
74
|
+
c.description = c.summary
|
75
|
+
c.example 'description', "flick info -p android\n flick info -p ios"
|
76
|
+
c.option '-p', '--platform PLATFORM', String, 'Set platform: android or ios'
|
77
|
+
c.option '-u', '--udid UDID', String, 'Set device UDID.'
|
78
|
+
c.option '-s', '--save SAVE', 'Save device info to a file.'
|
79
|
+
c.option '-o', '--outdir OUTDIR', String, "Save device info to file. Default is #{Dir.pwd}"
|
80
|
+
c.action do |args, options|
|
81
|
+
options.default \
|
82
|
+
:save => false,
|
83
|
+
:outdir => Dir.pwd #defaults to save in current directory.
|
84
|
+
|
85
|
+
Info.new(options.default).info
|
86
|
+
end
|
87
|
+
end
|
data/bin/setup
ADDED
data/flick.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'flick/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "flick"
|
8
|
+
spec.version = Flick::VERSION
|
9
|
+
spec.authors = ["Justin"]
|
10
|
+
spec.email = ["justin.ison@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A CLI to capture screenshots, video, logs, and device information for Android (Devices & Emulators) and iOS (Devices).}
|
13
|
+
spec.description = %q{A CLI with helpful QA tools for iOS and Android from the command line}
|
14
|
+
spec.homepage = "https://github.com/isonic1/flick"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
19
|
+
else
|
20
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
21
|
+
end
|
22
|
+
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
spec.bindir = "bin"
|
25
|
+
spec.executables = ["flick"]
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec", '~> 3.4', '>= 3.4.0'
|
31
|
+
spec.add_dependency "parallel", '~> 1.6', '>= 1.6.2'
|
32
|
+
spec.add_dependency "colorize", "~> 0.7.7"
|
33
|
+
spec.add_dependency "commander", '~> 4.4', '>= 4.4.0'
|
34
|
+
spec.add_dependency "json", '~> 1.8', '>= 1.8.3'
|
35
|
+
spec.add_dependency "wannabe_bool", "~> 0.5.0"
|
36
|
+
spec.add_dependency "awesome_print", '~> 1.6', '>= 1.6.1'
|
37
|
+
end
|
data/lib/flick.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'json'
|
3
|
+
require 'parallel'
|
4
|
+
require 'wannabe_bool'
|
5
|
+
require 'awesome_print'
|
6
|
+
|
7
|
+
require "flick/version"
|
8
|
+
require_relative "./flick/android"
|
9
|
+
require_relative "./flick/checker"
|
10
|
+
require_relative "./flick/info"
|
11
|
+
require_relative "./flick/ios"
|
12
|
+
require_relative "./flick/log"
|
13
|
+
require_relative "./flick/screenshot"
|
14
|
+
require_relative "./flick/simple_daemon"
|
15
|
+
require_relative "./flick/system"
|
16
|
+
require_relative "./flick/video"
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module Flick
|
2
|
+
class Android
|
3
|
+
attr_accessor :flick_dir, :dir_name, :udid, :name, :outdir, :unique, :limit, :specs
|
4
|
+
|
5
|
+
def initialize options
|
6
|
+
Flick::Checker.system_dependency "adb"
|
7
|
+
self.flick_dir = "#{Dir.home}/.flick"
|
8
|
+
self.dir_name = "sdcard/flick"
|
9
|
+
self.udid = options.fetch(:udid, get_device_udid(options))
|
10
|
+
self.name = options.fetch(:name, self.udid)
|
11
|
+
self.outdir = options.fetch(:outdir, Dir.pwd)
|
12
|
+
self.unique = options.fetch(:unique, true).to_b
|
13
|
+
self.limit = options.fetch(:limit, 180)
|
14
|
+
self.specs = options.fetch(:specs, false)
|
15
|
+
create_flick_dirs
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_flick_dirs
|
19
|
+
Flick::System.setup_system_dir flick_dir
|
20
|
+
%x(adb -s #{udid} shell 'mkdir #{dir_name}' >> /dev/null 2>&1)
|
21
|
+
end
|
22
|
+
|
23
|
+
def clear_files
|
24
|
+
%x(adb -s #{udid} shell rm '#{dir_name}/*' >> /dev/null 2>&1)
|
25
|
+
Flick::System.clean_system_dir flick_dir, udid
|
26
|
+
end
|
27
|
+
|
28
|
+
def devices
|
29
|
+
(`adb devices`).scan(/\n(.*)\t/).flatten
|
30
|
+
end
|
31
|
+
|
32
|
+
def devices_connected?
|
33
|
+
!devices.empty?
|
34
|
+
end
|
35
|
+
|
36
|
+
def check_for_devices
|
37
|
+
unless devices_connected?
|
38
|
+
puts "\nNo Devices Connected or Authorized!!!\nMake sure at least one device (emulator/simulator) is started!\n".red
|
39
|
+
abort
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_device_udid opts_hash
|
44
|
+
devices_connected?
|
45
|
+
return unless opts_hash[:udid].nil?
|
46
|
+
if devices.size == 1
|
47
|
+
devices[0]
|
48
|
+
else
|
49
|
+
puts "\nMultiple android devices '#{devices}' found.\nSpecify a single UDID. e.g. -u #{devices.sample}\n".red
|
50
|
+
abort unless specs
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def info
|
55
|
+
specs = { os: "ro.build.version.release", manufacturer: "ro.product.manufacturer", model: "ro.product.model", sdk: "ro.build.version.sdk" }
|
56
|
+
hash = { udid: udid }
|
57
|
+
specs.each do |key, spec|
|
58
|
+
value = `adb -s #{udid} shell getprop "#{spec}"`.strip
|
59
|
+
hash.merge!({key=> "#{value}"})
|
60
|
+
end
|
61
|
+
hash
|
62
|
+
end
|
63
|
+
|
64
|
+
def os_version
|
65
|
+
`adb -s #{udid} shell getprop "ro.build.version.release"`.strip.to_f
|
66
|
+
end
|
67
|
+
|
68
|
+
def screenshot name
|
69
|
+
%x(adb -s #{udid} shell screencap #{dir_name}/#{name}.png)
|
70
|
+
end
|
71
|
+
|
72
|
+
def log name
|
73
|
+
%x(adb -s #{udid} logcat -v long > #{outdir}/#{name}.log)
|
74
|
+
end
|
75
|
+
|
76
|
+
def recordable?
|
77
|
+
(`adb -s #{udid} shell 'ls /system/bin/screenrecord'`).strip == "/system/bin/screenrecord"
|
78
|
+
end
|
79
|
+
|
80
|
+
def screenrecord name
|
81
|
+
%x(adb -s #{udid} shell screenrecord --time-limit #{limit} --size 720x1280 #{dir_name}/#{name}.mp4)
|
82
|
+
end
|
83
|
+
|
84
|
+
def pull_file file, dir
|
85
|
+
%x(adb -s #{udid} pull #{file} #{dir} >> /dev/null 2>&1)
|
86
|
+
end
|
87
|
+
|
88
|
+
def unique_files
|
89
|
+
if os_version < 6.0
|
90
|
+
command = "md5"
|
91
|
+
else
|
92
|
+
command = "md5sum"
|
93
|
+
end
|
94
|
+
files = `adb -s #{udid} shell "#{command} #{dir_name}/#{udid}*"`
|
95
|
+
hash = files.split("\r\n").map { |file| { md5: file.match(/(.*) /)[1].strip, file: file.match(/ (.*)/)[1].strip } }
|
96
|
+
hash.uniq! { |e| e[:md5] }
|
97
|
+
hash.map { |file| file[:file] }
|
98
|
+
end
|
99
|
+
|
100
|
+
def pull_files
|
101
|
+
if unique
|
102
|
+
files = unique_files
|
103
|
+
else
|
104
|
+
files = (`adb -s #{udid} shell "ls #{dir_name}/#{udid}*"`).split("\r\n")
|
105
|
+
end
|
106
|
+
return if files.empty?
|
107
|
+
Parallel.map(files, in_threads: 10) { |file| pull_file file, flick_dir }
|
108
|
+
end
|
109
|
+
|
110
|
+
def screenshots_exist?
|
111
|
+
(`adb -s #{udid} shell "ls #{dir_name}/#{udid}-*.png | wc -l"`).to_i > 0
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Flick
|
2
|
+
module Checker
|
3
|
+
def self.system_dependency dep
|
4
|
+
program = `which #{dep}`
|
5
|
+
if program.empty?
|
6
|
+
puts "\n#{dep} was not found. Please ensure you have installed #{dep} and it's in your $PATH\n".red
|
7
|
+
abort
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.platform platform
|
12
|
+
platforms = ["android","ios"]
|
13
|
+
unless platforms.include? platform
|
14
|
+
puts "\nPlease specify a valid platform #{platforms}. e.g. flick <job> -a start -p #{platforms.sample}\n".red
|
15
|
+
abort
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.action action
|
20
|
+
actions = ["start","stop"]
|
21
|
+
unless actions.include? action
|
22
|
+
puts "\nPlease specify a valid action #{actions}. e.g. flick <job> -a #{actions.sample} -p ios\n".red
|
23
|
+
abort
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.format format
|
28
|
+
formats = ["mp4","gif"]
|
29
|
+
unless formats.include? format
|
30
|
+
puts "\nPlease specify a valid format #{formats}. e.g. flick <job> -a stop -p ios -f #{formats.sample}\n".red
|
31
|
+
abort
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/flick/info.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
class Info
|
2
|
+
|
3
|
+
attr_accessor :platform, :driver, :save
|
4
|
+
|
5
|
+
def initialize options
|
6
|
+
Flick::Checker.platform options[:platform]
|
7
|
+
self.platform = options[:platform]
|
8
|
+
case @platform
|
9
|
+
when "ios"
|
10
|
+
options[:todir] = options[:outdir]
|
11
|
+
self.driver = Flick::Ios.new options
|
12
|
+
when "android"
|
13
|
+
self.driver = Flick::Android.new options
|
14
|
+
end
|
15
|
+
self.save = options[:save].to_b
|
16
|
+
end
|
17
|
+
|
18
|
+
def save_device_data info
|
19
|
+
info.each do |k,v|
|
20
|
+
open("#{driver.outdir}/info-#{driver.udid}.log", 'a') do |file|
|
21
|
+
file << "#{k}: #{v}\n"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def info
|
27
|
+
ap driver.info
|
28
|
+
if save
|
29
|
+
puts "Saving to #{driver.outdir}/info-#{driver.name}.log"
|
30
|
+
save_device_data driver.info
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/flick/ios.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
module Flick
|
2
|
+
class Ios
|
3
|
+
attr_accessor :flick_dir, :udid, :name, :outdir, :todir, :specs
|
4
|
+
|
5
|
+
def initialize options
|
6
|
+
Flick::Checker.system_dependency "idevice_id"
|
7
|
+
self.flick_dir = "#{Dir.home}/.flick"
|
8
|
+
self.udid = options.fetch(:udid, get_device_udid(options))
|
9
|
+
self.name = options.fetch(:name, self.udid)
|
10
|
+
self.todir = options.fetch(:todir, self.flick_dir)
|
11
|
+
self.outdir = options.fetch(:outdir, Dir.pwd)
|
12
|
+
self.specs = options.fetch(:specs, false)
|
13
|
+
create_flick_dirs
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_flick_dirs
|
17
|
+
Flick::System.setup_system_dir flick_dir
|
18
|
+
end
|
19
|
+
|
20
|
+
def devices
|
21
|
+
(`idevice_id -l`).split.uniq.map { |d| d }
|
22
|
+
end
|
23
|
+
|
24
|
+
def devices_connected?
|
25
|
+
!devices.empty?
|
26
|
+
end
|
27
|
+
|
28
|
+
def check_for_devices
|
29
|
+
unless devices_connected?
|
30
|
+
puts "\nNo iPhone or iPad Devices Connected!!!\nMake sure at least one REAL device is connected!\n".red
|
31
|
+
abort
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_device_udid opts_hash
|
36
|
+
check_for_devices
|
37
|
+
return unless opts_hash[:udid].nil?
|
38
|
+
if devices.size == 1
|
39
|
+
devices[0]
|
40
|
+
else
|
41
|
+
puts "\nMultiple iOS devices '#{devices}' found.\nSpecify a single UDID. e.g. -u #{devices.sample}\n".red
|
42
|
+
abort unless specs
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def info
|
47
|
+
specs = { os: "ProductVersion", name: "DeviceName", arc: "CPUArchitecture", type: "DeviceClass", sdk: "ProductType" }
|
48
|
+
hash = { udid: udid }
|
49
|
+
specs.each do |key, spec|
|
50
|
+
value = (`ideviceinfo -u #{udid} | grep #{spec} | awk '{$1=""; print $0}'`).strip
|
51
|
+
hash.merge!({key=> "#{value}"})
|
52
|
+
end
|
53
|
+
hash
|
54
|
+
end
|
55
|
+
|
56
|
+
def recordable?
|
57
|
+
false
|
58
|
+
end
|
59
|
+
|
60
|
+
def clear_files
|
61
|
+
Flick::System.clean_system_dir flick_dir, udid
|
62
|
+
end
|
63
|
+
|
64
|
+
def screenshot name
|
65
|
+
Flick::Checker.system_dependency "idevicescreenshot"
|
66
|
+
%x(idevicescreenshot -u #{udid} #{todir}/#{name}.png)
|
67
|
+
end
|
68
|
+
|
69
|
+
def log name
|
70
|
+
Flick::Checker.system_dependency "idevicesyslog"
|
71
|
+
%x(idevicesyslog -u #{udid} > #{outdir}/#{name}.log)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/flick/log.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
class Log
|
2
|
+
|
3
|
+
attr_accessor :action, :platform, :driver, :udid
|
4
|
+
|
5
|
+
def initialize options
|
6
|
+
Flick::Checker.action options[:action]
|
7
|
+
Flick::Checker.platform options[:platform]
|
8
|
+
self.action = options[:action]
|
9
|
+
self.platform = options[:platform]
|
10
|
+
case @platform
|
11
|
+
when "ios"
|
12
|
+
options[:todir] = options[:outdir]
|
13
|
+
self.driver = Flick::Ios.new options
|
14
|
+
when "android"
|
15
|
+
self.driver = Flick::Android.new options
|
16
|
+
end
|
17
|
+
self.udid = self.driver.udid
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
self.send(action)
|
22
|
+
end
|
23
|
+
|
24
|
+
def start
|
25
|
+
puts "Saving to #{driver.outdir}/#{driver.name}.log"
|
26
|
+
log
|
27
|
+
end
|
28
|
+
|
29
|
+
def stop
|
30
|
+
Flick::System.kill_process "log", udid
|
31
|
+
end
|
32
|
+
|
33
|
+
def log
|
34
|
+
stop
|
35
|
+
$0 = "flick-log-#{udid}"
|
36
|
+
SimpleDaemon.daemonize! "/tmp/#{udid}-pidfile"
|
37
|
+
command = -> do
|
38
|
+
driver.log driver.name
|
39
|
+
end
|
40
|
+
command.call
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Screenshot
|
2
|
+
|
3
|
+
attr_accessor :platform, :driver
|
4
|
+
|
5
|
+
def initialize options
|
6
|
+
Flick::Checker.platform options[:platform]
|
7
|
+
self.platform = options[:platform]
|
8
|
+
case @platform
|
9
|
+
when "ios"
|
10
|
+
options[:todir] = options[:outdir]
|
11
|
+
self.driver = Flick::Ios.new options
|
12
|
+
when "android"
|
13
|
+
self.driver = Flick::Android.new options
|
14
|
+
end
|
15
|
+
setup
|
16
|
+
end
|
17
|
+
|
18
|
+
def screenshot
|
19
|
+
puts "Saving to #{driver.outdir}/#{driver.name}.png"
|
20
|
+
driver.screenshot driver.name
|
21
|
+
driver.pull_file "#{driver.dir_name}/#{driver.name}.png", driver.outdir if platform == "android"
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def setup
|
27
|
+
driver.clear_files
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# https://gist.githubusercontent.com/mynameisrufus/1372491/raw/b76b60fb1842bf0507f47869ab19ad50a045b214/simple_daemon.rb
|
4
|
+
#
|
5
|
+
# == Double-forking Unix daemon
|
6
|
+
#
|
7
|
+
# Author:: Rufus Post (mailto:rufuspost@gmail.com)
|
8
|
+
#
|
9
|
+
# === How does it work?
|
10
|
+
#
|
11
|
+
# According to Stevens's Advanced Programming in the UNIX Environment
|
12
|
+
# chapter 13, this is the procedure to make a well-behaved Unix daemon:
|
13
|
+
#
|
14
|
+
# Fork and have the parent exit. This makes the shell or boot script
|
15
|
+
# think the command is done. Also, the child process is guaranteed not
|
16
|
+
# to be a process group leader (a prerequisite for setsid next)
|
17
|
+
# Call setsid to create a new session. This does three things:
|
18
|
+
# * The process becomes a session leader of a new session
|
19
|
+
# * The process becomes the process group leader of a new process group
|
20
|
+
# * The process has no controlling terminal
|
21
|
+
#
|
22
|
+
# Optionally fork again and have the parent exit. This guarantes that
|
23
|
+
# the daemon is not a session leader nor can it acquire a controlling
|
24
|
+
# terminal (under SVR4)
|
25
|
+
#
|
26
|
+
# grandparent - the current process
|
27
|
+
# \_ parent - exits immediately
|
28
|
+
# \_ simple daemon - writes out its pid to file
|
29
|
+
#
|
30
|
+
# Change the current working directory to / to avoid interfering with
|
31
|
+
# mounting and unmounting. By default don't bother to chdir("/") here
|
32
|
+
# because we might to run inside APP_ROOT.
|
33
|
+
#
|
34
|
+
# Set file mode creation mask to 000 to allow creation of files with any
|
35
|
+
# required permission later. By default umask is whatever was set by the
|
36
|
+
# parent process at startup and can be set in config.ru and config_file,
|
37
|
+
# so making it 0000 and potentially exposing sensitive log data can be
|
38
|
+
# bad policy.
|
39
|
+
#
|
40
|
+
# Close unneeded file descriptors inherited from the parent (there is no
|
41
|
+
# controlling terminal anyway): stdout, stderr, and stdin.
|
42
|
+
#
|
43
|
+
# Nowadays there is a file to track the PID which is used heavily by
|
44
|
+
# Linux distribution boot scripts. Be sure to write out the PID of the
|
45
|
+
# grandchild, either the return value of the second fork (step 3) or the
|
46
|
+
# value of getpid() after step 3.
|
47
|
+
#
|
48
|
+
class SimpleDaemon
|
49
|
+
# In the directory where you want your daemon add a git submodule to
|
50
|
+
# your project and create a daemon launcher script:
|
51
|
+
#
|
52
|
+
# #!/usr/bin/env ruby
|
53
|
+
#
|
54
|
+
# require 'simple_daemon'
|
55
|
+
#
|
56
|
+
# $0 = "my daemon"
|
57
|
+
#
|
58
|
+
# SimpleDaemon.daemonize! ARGV[0], ARGV[1], ARGV[2]
|
59
|
+
#
|
60
|
+
# loop do
|
61
|
+
# sleep 5
|
62
|
+
# puts "tick"
|
63
|
+
# sleep 5
|
64
|
+
# puts "tock"
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# make your script executable and run:
|
68
|
+
#
|
69
|
+
# $ chmod +x launcher
|
70
|
+
# $ launcher tmp/daemon.pid log/daemon.stdout.log log/daemon.stderr.log
|
71
|
+
#
|
72
|
+
# check that it is running by with the following:
|
73
|
+
#
|
74
|
+
# $ ps aux | grep "my daemon"
|
75
|
+
#
|
76
|
+
#
|
77
|
+
def self.daemonize! pidfile, out = '/dev/null', err = '/dev/null', safe = true
|
78
|
+
raise 'First fork failed' if (pid = fork) == -1
|
79
|
+
exit unless pid.nil?
|
80
|
+
Process.setsid
|
81
|
+
raise 'Second fork failed' if (pid = fork) == -1
|
82
|
+
exit unless pid.nil?
|
83
|
+
kill pidfile
|
84
|
+
write Process.pid, pidfile
|
85
|
+
unless safe
|
86
|
+
Dir.chdir '/'
|
87
|
+
File.umask 0000
|
88
|
+
end
|
89
|
+
redirect out, err
|
90
|
+
end
|
91
|
+
|
92
|
+
# Attempts to write the pid of the forked process to the pid file.
|
93
|
+
# Kills process if write unsuccesfull.
|
94
|
+
def self.write pid, pidfile
|
95
|
+
File.open pidfile, "w" do |f|
|
96
|
+
f.write pid
|
97
|
+
f.close
|
98
|
+
end
|
99
|
+
$stdout.puts "Daemon running with pid: #{pid}"
|
100
|
+
rescue ::Exception => e
|
101
|
+
raise "While writing the PID to file, unexpected #{e.class}: #{e}"
|
102
|
+
end
|
103
|
+
|
104
|
+
# Try and read the existing pid from the pid file and signal HUP to
|
105
|
+
# process.
|
106
|
+
def self.kill pidfile
|
107
|
+
opid = open(pidfile).read.strip.to_i
|
108
|
+
Process.kill "HUP", opid
|
109
|
+
rescue TypeError
|
110
|
+
$stdout.puts "#{pidfile} was empty: TypeError"
|
111
|
+
rescue Errno::ENOENT
|
112
|
+
#$stdout.puts "#{pidfile} did not exist: Errno::ENOENT"
|
113
|
+
rescue Errno::ESRCH
|
114
|
+
#$stdout.puts "The process #{opid} did not exist: Errno::ESRCH"
|
115
|
+
rescue Errno::EPERM
|
116
|
+
raise "Lack of privileges to manage the process #{opid}: Errno::EPERM"
|
117
|
+
rescue ::Exception => e
|
118
|
+
raise "While signaling the PID, unexpected #{e.class}: #{e}"
|
119
|
+
end
|
120
|
+
|
121
|
+
# Redirect file descriptors inherited from the parent.
|
122
|
+
def self.redirect out, err
|
123
|
+
$stdin.reopen '/dev/null'
|
124
|
+
$stdout.reopen File.new(out, "a")
|
125
|
+
$stderr.reopen File.new(err, "a")
|
126
|
+
$stdout.sync = $stderr.sync = true
|
127
|
+
end
|
128
|
+
end
|
data/lib/flick/system.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Flick
|
2
|
+
module System
|
3
|
+
def self.setup_system_dir dir_name
|
4
|
+
%x(mkdir #{dir_name} >> /dev/null 2>&1)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.clean_system_dir dir_name, udid
|
8
|
+
%x(rm #{dir_name}/#{udid}* >> /dev/null 2>&1)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.process_running? type, udid
|
12
|
+
`pgrep -f #{type}-#{udid}`.to_i > 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.kill_process type, udid
|
16
|
+
if self.process_running? type, udid
|
17
|
+
pid = `pgrep -f flick-#{type}-#{udid}`.to_i
|
18
|
+
`kill #{pid}` unless pid.zero?
|
19
|
+
end
|
20
|
+
if type == "video"
|
21
|
+
pid = `pgrep -f #{udid}-`.to_i
|
22
|
+
`kill #{pid}` unless pid.zero?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.video_length file
|
27
|
+
(`ffmpeg -i #{file} 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//`).strip
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/flick/video.rb
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
class Video
|
2
|
+
|
3
|
+
attr_accessor :action, :platform, :driver, :image_count, :seconds, :extended, :udid, :format
|
4
|
+
|
5
|
+
def initialize options
|
6
|
+
Flick::Checker.action options[:action]
|
7
|
+
Flick::Checker.platform options[:platform]
|
8
|
+
Flick::Checker.format options[:format]
|
9
|
+
self.action = options[:action]
|
10
|
+
self.platform = options[:platform]
|
11
|
+
case self.platform
|
12
|
+
when "ios"
|
13
|
+
self.driver = Flick::Ios.new options
|
14
|
+
when "android"
|
15
|
+
self.driver = Flick::Android.new options
|
16
|
+
end
|
17
|
+
self.image_count = options[:count]
|
18
|
+
self.seconds = options[:seconds].to_f
|
19
|
+
self.extended = options[:extend].to_b
|
20
|
+
self.udid = self.driver.udid
|
21
|
+
self.format = options[:format]
|
22
|
+
end
|
23
|
+
|
24
|
+
def android
|
25
|
+
platform == "android"
|
26
|
+
end
|
27
|
+
|
28
|
+
def ios
|
29
|
+
platform == "ios"
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
self.send(action)
|
34
|
+
end
|
35
|
+
|
36
|
+
def start
|
37
|
+
driver.clear_files
|
38
|
+
puts "\nStarting Recoder!!!"
|
39
|
+
if driver.recordable?
|
40
|
+
if extended
|
41
|
+
puts "In extended mode."
|
42
|
+
Flick::Checker.system_dependency "mp4box"
|
43
|
+
loop_record
|
44
|
+
else
|
45
|
+
start_record
|
46
|
+
end
|
47
|
+
else
|
48
|
+
Flick::Checker.system_dependency "ffmpeg"
|
49
|
+
start_screenshot_record
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def stop
|
54
|
+
puts "\nStopping Recorder!!!"
|
55
|
+
if driver.recordable?
|
56
|
+
stop_record
|
57
|
+
else
|
58
|
+
stop_screenshot_recording
|
59
|
+
end
|
60
|
+
sleep 1
|
61
|
+
driver.clear_files
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def start_record
|
67
|
+
Flick::System.kill_process "video", udid
|
68
|
+
$0 = "flick-video-#{udid}"
|
69
|
+
SimpleDaemon.daemonize! "/tmp/#{udid}-pidfile"
|
70
|
+
command = -> do
|
71
|
+
driver.screenrecord "#{udid}-single"
|
72
|
+
end
|
73
|
+
command.call
|
74
|
+
end
|
75
|
+
|
76
|
+
def is_recording?
|
77
|
+
!(`pgrep -f #{udid}-`).empty?
|
78
|
+
end
|
79
|
+
|
80
|
+
def loop_record
|
81
|
+
Flick::System.kill_process "video", udid
|
82
|
+
$0 = "flick-video-#{udid}"
|
83
|
+
SimpleDaemon.daemonize! "/tmp/#{udid}-pidfile"
|
84
|
+
command = -> do
|
85
|
+
count = "%03d" % 1
|
86
|
+
loop do
|
87
|
+
unless is_recording?
|
88
|
+
driver.screenrecord "#{udid}-#{count}"
|
89
|
+
count.next!
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
command.call
|
94
|
+
end
|
95
|
+
|
96
|
+
def stop_record
|
97
|
+
Flick::System.kill_process "video", udid
|
98
|
+
sleep 5 #wait for video process to finish
|
99
|
+
driver.pull_files
|
100
|
+
files = (`ls #{driver.flick_dir}/#{udid}*.mp4`).split("\n")
|
101
|
+
return if files.empty?
|
102
|
+
files.each { |file| system("mp4box -cat #{file} #{driver.flick_dir}/#{driver.name}.mp4") }
|
103
|
+
puts "Saving to #{driver.outdir}/#{driver.name}.#{format}"
|
104
|
+
if format == "gif"
|
105
|
+
gif
|
106
|
+
else
|
107
|
+
%x(nohup mv #{driver.flick_dir}/#{driver.name}.mp4 #{driver.outdir}/#{driver.name}.mp4)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def start_screenshot_record
|
112
|
+
Flick::System.kill_process "screenshot", udid
|
113
|
+
puts "Process will stop after #{image_count} screenshots.\n"
|
114
|
+
$0 = "flick-screenshot-#{udid}"
|
115
|
+
SimpleDaemon.daemonize! "/tmp/#{udid}-pidfile"
|
116
|
+
command = -> do
|
117
|
+
count = "%03d" % 1
|
118
|
+
loop do
|
119
|
+
if count.to_i < image_count
|
120
|
+
driver.screenshot "#{udid}-#{count}"
|
121
|
+
count.next!; sleep seconds
|
122
|
+
else
|
123
|
+
puts "\nStop count exceeded. Saving to #{driver.outdir}/#{driver.name}.#{format}".red
|
124
|
+
self.send(format)
|
125
|
+
break
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
command.call
|
130
|
+
end
|
131
|
+
|
132
|
+
def stop_screenshot_recording
|
133
|
+
Flick::System.kill_process "screenshot", udid
|
134
|
+
`rm /tmp/#{udid}-pidfile >> /dev/null 2>&1`
|
135
|
+
driver.pull_files if android
|
136
|
+
puts "Saving to #{driver.outdir}/#{driver.name}.#{format}"
|
137
|
+
self.send(format)
|
138
|
+
end
|
139
|
+
|
140
|
+
def gif
|
141
|
+
convert_images_to_mp4 unless driver.recordable?
|
142
|
+
%x(nohup ffmpeg -i #{driver.flick_dir}/#{driver.name}.mp4 -pix_fmt rgb24 #{driver.outdir}/#{driver.name}.gif)
|
143
|
+
end
|
144
|
+
|
145
|
+
def mp4
|
146
|
+
convert_images_to_mp4
|
147
|
+
%x(nohup mv #{driver.flick_dir}/#{driver.name}.mp4 #{driver.outdir}/#{driver.name}.mp4) unless format == "gif"
|
148
|
+
end
|
149
|
+
|
150
|
+
def convert_images_to_mp4
|
151
|
+
remove_zero_byte_images
|
152
|
+
%x(nohup ffmpeg -framerate 1 -pattern_type glob -i '#{driver.flick_dir}/#{udid}*.png' -c:v libx264 -pix_fmt yuv420p #{driver.flick_dir}/#{driver.name}.mp4)
|
153
|
+
end
|
154
|
+
|
155
|
+
def remove_zero_byte_images
|
156
|
+
%x(nohup find #{driver.flick_dir} -type f -size 0 | xargs rm '#{udid}*.png' -f)
|
157
|
+
end
|
158
|
+
end
|
metadata
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flick
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 3.4.0
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.4'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.4.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: parallel
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.6'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.6.2
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.6'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.6.2
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: colorize
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 0.7.7
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.7.7
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: commander
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '4.4'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 4.4.0
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '4.4'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 4.4.0
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: json
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '1.8'
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.8.3
|
125
|
+
type: :runtime
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.8'
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 1.8.3
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: wannabe_bool
|
137
|
+
requirement: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 0.5.0
|
142
|
+
type: :runtime
|
143
|
+
prerelease: false
|
144
|
+
version_requirements: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - "~>"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: 0.5.0
|
149
|
+
- !ruby/object:Gem::Dependency
|
150
|
+
name: awesome_print
|
151
|
+
requirement: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - "~>"
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '1.6'
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 1.6.1
|
159
|
+
type: :runtime
|
160
|
+
prerelease: false
|
161
|
+
version_requirements: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '1.6'
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: 1.6.1
|
169
|
+
description: A CLI with helpful QA tools for iOS and Android from the command line
|
170
|
+
email:
|
171
|
+
- justin.ison@gmail.com
|
172
|
+
executables:
|
173
|
+
- flick
|
174
|
+
extensions: []
|
175
|
+
extra_rdoc_files: []
|
176
|
+
files:
|
177
|
+
- ".gitignore"
|
178
|
+
- ".rspec"
|
179
|
+
- ".travis.yml"
|
180
|
+
- CODE_OF_CONDUCT.md
|
181
|
+
- Gemfile
|
182
|
+
- LICENSE.txt
|
183
|
+
- README.md
|
184
|
+
- Rakefile
|
185
|
+
- bin/console
|
186
|
+
- bin/flick
|
187
|
+
- bin/setup
|
188
|
+
- flick.gemspec
|
189
|
+
- lib/flick.rb
|
190
|
+
- lib/flick/android.rb
|
191
|
+
- lib/flick/checker.rb
|
192
|
+
- lib/flick/info.rb
|
193
|
+
- lib/flick/ios.rb
|
194
|
+
- lib/flick/log.rb
|
195
|
+
- lib/flick/screenshot.rb
|
196
|
+
- lib/flick/simple_daemon.rb
|
197
|
+
- lib/flick/system.rb
|
198
|
+
- lib/flick/version.rb
|
199
|
+
- lib/flick/video.rb
|
200
|
+
homepage: https://github.com/isonic1/flick
|
201
|
+
licenses:
|
202
|
+
- MIT
|
203
|
+
metadata:
|
204
|
+
allowed_push_host: https://rubygems.org
|
205
|
+
post_install_message:
|
206
|
+
rdoc_options: []
|
207
|
+
require_paths:
|
208
|
+
- lib
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
requirements: []
|
220
|
+
rubyforge_project:
|
221
|
+
rubygems_version: 2.5.2
|
222
|
+
signing_key:
|
223
|
+
specification_version: 4
|
224
|
+
summary: A CLI to capture screenshots, video, logs, and device information for Android
|
225
|
+
(Devices & Emulators) and iOS (Devices).
|
226
|
+
test_files: []
|
227
|
+
has_rdoc:
|