flick 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb64107c4d21b8fc509321fdc0d98763e3e376e6
4
- data.tar.gz: 154aa4c74efa4fead2f6cdd5880c7b71602607ed
3
+ metadata.gz: 25b3b0bb28400f0565fbefc0d417669209bd4ced
4
+ data.tar.gz: 4a160eaf8cc1795844a13b750d422c6b49e6026c
5
5
  SHA512:
6
- metadata.gz: 07dba93a03a97b5a725bc98afca7e3cda8c66138aab7ae1f15efaa6f3caf4a43a01599344117130f04f54391ef6c40629178b66e714c5693e0d1dacd7f026c43
7
- data.tar.gz: 7e400657a20828488546d0229b251fe3bbe7a125c25aee55eb23aba1cc41fdc275b0d2aa6bd4c76c1c04295194e535fdd2bddab91a18486db83214081abd991e
6
+ metadata.gz: e5ba77b5cc0d06dd1d67f449f1f435e3cb85b61e4237b77a9a46e0206b6e53ece52f5322c80b89a6ecbb5995c70aa51d2d3b91283abbe6c540733e44550b9ac7
7
+ data.tar.gz: 32ec8cc036ab3138bbd9f1a6da07c1b0fb864f2e988a47631a0e835eb26f2defd30daa33921d6e40e529d7a7b755bb44ac11f6ad682f41703fb512b22c362c4d
data/README.md CHANGED
@@ -20,6 +20,8 @@ Features
20
20
  * Flick auto selects device when only one device is connected, per platform.
21
21
  * Save log output for Android or iOS.
22
22
  * Display device information or save it to a file.
23
+ * Install or Uninstall applications from devices.
24
+ * Checkout the latest release notes [here](https://github.com/isonic1/flick/releases).
23
25
 
24
26
  Reason
25
27
  ------
@@ -34,15 +36,8 @@ Prerequisites
34
36
  #### System Tools
35
37
  * Install ffmpeg. [OSX](https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX)
36
38
  * ```$ brew install ffmpeg```
37
- * Install ffmpeg. [Windows](https://ffmpeg.zeranoe.com/builds/)
38
- * Download either the 32-bit or 64-bit static versions.
39
- * Extract the zip file and move the ffmpeg folder somewhere else.
40
- * Add the ffmpeg bin location to your PATH user variables. e.g. C:\ffmpeg\bin
41
39
  * Install mp4box. [OSX](http://hunterford.me/compiling-mp4box-on-mac-os-x/)
42
40
  * ```$ brew install mp4box```
43
- * Install mp4box. [Windows](http://www.videohelp.com/software/MP4Box)
44
- * Run the gpac-0.6.2-DEV-rev634-gd2332cb-master-x(64 or 32 bit).exe
45
- * Select to install only the MP4Box component.
46
41
 
47
42
  #### Android
48
43
  * Install [SDK Tools](http://developer.android.com/sdk/installing/index.html?pkg=tools).
data/bin/flick CHANGED
@@ -2,7 +2,7 @@
2
2
  require_relative '../lib/flick'
3
3
  require 'commander/import'
4
4
 
5
- program :version, '0.0.1'
5
+ program :version, '0.3.1'
6
6
  program :description, 'A CLI to capture screenshots, video, logs, and device info for Android (Devices & Emulators) and iOS (Devices).'
7
7
 
8
8
  command :video do |c|
data/flick.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "rake", "~> 10.0"
30
30
  spec.add_development_dependency "rspec", '~> 3.4', '>= 3.4.0'
31
31
  spec.add_dependency "parallel", '~> 1.6', '>= 1.6.2'
32
- spec.add_dependency "colorize", "~> 0.7.7"
32
+ spec.add_dependency "colorize", "~> 0.8.1"
33
33
  spec.add_dependency "commander", '~> 4.4', '>= 4.4.0'
34
34
  spec.add_dependency "json", '~> 1.8', '>= 1.8.3'
35
35
  spec.add_dependency "wannabe_bool", "~> 0.5.0"
data/lib/flick/android.rb CHANGED
@@ -1,13 +1,17 @@
1
1
  module Flick
2
2
  class Android
3
- attr_accessor :flick_dir, :dir_name, :udid, :name, :outdir, :unique, :limit, :specs
3
+ attr_accessor :udid, :flick_dir, :dir_name, :name, :outdir, :unique, :limit, :specs
4
4
 
5
5
  def initialize options
6
6
  Flick::Checker.system_dependency "adb"
7
- self.flick_dir = "#{Dir.home}/.flick"
7
+ if options[:udid].nil?
8
+ self.udid = get_device_udid
9
+ else
10
+ self.udid = options[:udid]
11
+ end
12
+ self.flick_dir = "#{Dir.home}/.flick/#{udid}"
8
13
  self.dir_name = "sdcard/flick"
9
- self.udid = options.fetch(:udid, get_device_udid(options))
10
- self.name = options.fetch(:name, self.udid)
14
+ self.name = remove_bad_characters(options.fetch(:name, self.udid))
11
15
  self.outdir = options.fetch(:outdir, Dir.pwd)
12
16
  self.unique = options.fetch(:unique, true).to_b
13
17
  self.limit = options.fetch(:limit, 180)
@@ -15,13 +19,18 @@ module Flick
15
19
  create_flick_dirs
16
20
  end
17
21
 
22
+ def remove_bad_characters string
23
+ string.gsub(/[\x00\/\\:\*\?\"<>\|]/, '_')
24
+ end
25
+
18
26
  def create_flick_dirs
27
+ Flick::System.setup_system_dir "#{Dir.home}/.flick"
19
28
  Flick::System.setup_system_dir flick_dir
20
29
  %x(adb -s #{udid} shell 'mkdir #{dir_name}')
21
30
  end
22
31
 
23
32
  def clear_files
24
- Flick::System.clean_system_dir flick_dir, udid
33
+ Flick::System.clean_system_dir flick_dir
25
34
  %x(adb -s #{udid} shell rm '#{dir_name}/*')
26
35
  end
27
36
 
@@ -40,9 +49,8 @@ module Flick
40
49
  end
41
50
  end
42
51
 
43
- def get_device_udid opts_hash
44
- devices_connected?
45
- return unless opts_hash[:udid].nil?
52
+ def get_device_udid
53
+ check_for_devices
46
54
  if devices.size == 1
47
55
  devices.first
48
56
  else
@@ -109,7 +117,11 @@ module Flick
109
117
  end
110
118
 
111
119
  def recordable?
112
- %x(adb -s #{udid} shell "ls /system/bin/screenrecord").strip == "/system/bin/screenrecord"
120
+ if info[:manufacturer] == "Genymotion"
121
+ return false
122
+ else
123
+ %x(adb -s #{udid} shell "ls /system/bin/screenrecord").strip == "/system/bin/screenrecord"
124
+ end
113
125
  end
114
126
 
115
127
  def screenrecord name
@@ -126,7 +138,7 @@ module Flick
126
138
  else
127
139
  command = "md5sum"
128
140
  end
129
- files = %x(adb -s #{udid} shell "#{command} #{dir_name}/#{type}-#{udid}*")
141
+ files = %x(adb -s #{udid} shell "#{command} #{dir_name}/#{type}*")
130
142
  hash = files.split("\r\n").map { |file| { md5: file.match(/(.*) /)[1].strip, file: file.match(/ (.*)/)[1].strip } }
131
143
  hash.uniq! { |e| e[:md5] }
132
144
  hash.map { |file| file[:file] }
@@ -136,7 +148,7 @@ module Flick
136
148
  if unique
137
149
  files = unique_files type
138
150
  else
139
- files = %x(adb -s #{udid} shell "ls #{dir_name}/#{type}-#{udid}*").split("\r\n")
151
+ files = %x(adb -s #{udid} shell "ls #{dir_name}/#{type}*").split("\r\n")
140
152
  end
141
153
  return if files.empty?
142
154
  Parallel.map(files, in_threads: 10) { |file| pull_file file, flick_dir }
data/lib/flick/checker.rb CHANGED
@@ -13,7 +13,7 @@ module Flick
13
13
 
14
14
  def self.system_dependency dep
15
15
  program = self.which dep
16
- if program.empty?
16
+ if program.nil? || program.empty?
17
17
  puts "\n#{dep} was not found. Please ensure you have installed #{dep} and it's in your $PATH\n".red
18
18
  abort
19
19
  end
data/lib/flick/info.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class Info
2
-
2
+
3
3
  attr_accessor :platform, :driver, :save
4
-
4
+
5
5
  def initialize options
6
6
  Flick::Checker.platform options[:platform]
7
7
  self.platform = options[:platform]
@@ -14,15 +14,7 @@ class Info
14
14
  end
15
15
  self.save = options[:save].to_b
16
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
-
17
+
26
18
  def info
27
19
  ap driver.info
28
20
  if save
@@ -30,4 +22,14 @@ class Info
30
22
  save_device_data driver.info
31
23
  end
32
24
  end
25
+
26
+ private
27
+
28
+ def save_device_data info
29
+ info.each do |k,v|
30
+ open("#{driver.outdir}/info-#{driver.name}.log", 'a') do |file|
31
+ file << "#{k}: #{v}\n"
32
+ end
33
+ end
34
+ end
33
35
  end
data/lib/flick/ios.rb CHANGED
@@ -3,21 +3,26 @@ module Flick
3
3
  attr_accessor :flick_dir, :udid, :name, :outdir, :todir, :specs
4
4
 
5
5
  def initialize options
6
- Flick::Checker.system_dependency "idevice_id"
7
- self.flick_dir = "#{Dir.home}/.flick"
8
6
  self.udid = options.fetch(:udid, get_device_udid(options))
9
- self.name = options.fetch(:name, self.udid)
7
+ self.flick_dir = "#{Dir.home}/.flick/#{udid}"
8
+ self.name = remove_bad_characters(options.fetch(:name, self.udid))
10
9
  self.todir = options.fetch(:todir, self.flick_dir)
11
10
  self.outdir = options.fetch(:outdir, Dir.pwd)
12
11
  self.specs = options.fetch(:specs, false)
13
12
  create_flick_dirs
14
13
  end
15
14
 
15
+ def remove_bad_characters string
16
+ string.gsub(/[\x00\/\\:\*\?\"<>\|]/, '_')
17
+ end
18
+
16
19
  def create_flick_dirs
20
+ Flick::System.setup_system_dir "#{Dir.home}/.flick"
17
21
  Flick::System.setup_system_dir flick_dir
18
22
  end
19
23
 
20
24
  def devices
25
+ Flick::Checker.system_dependency "idevice_id"
21
26
  (`idevice_id -l`).split.uniq.map { |d| d }
22
27
  end
23
28
 
@@ -58,7 +63,7 @@ module Flick
58
63
  end
59
64
 
60
65
  def clear_files
61
- Flick::System.clean_system_dir flick_dir, udid
66
+ Flick::System.clean_system_dir flick_dir
62
67
  end
63
68
 
64
69
  def screenshot name
data/lib/flick/log.rb CHANGED
@@ -17,14 +17,6 @@ class Log
17
17
  self.udid = self.driver.udid
18
18
  end
19
19
 
20
- def android
21
- platform == "android"
22
- end
23
-
24
- def ios
25
- platform == "ios"
26
- end
27
-
28
20
  def run
29
21
  self.send(action)
30
22
  end
@@ -45,8 +37,18 @@ class Log
45
37
  $0 = "flick-log-#{udid}"
46
38
  SimpleDaemon.daemonize!
47
39
  command = -> do
48
- driver.log driver.name
40
+ driver.log "#{driver.name}"
49
41
  end
50
42
  command.call
51
43
  end
44
+
45
+ private
46
+
47
+ def android
48
+ platform == "android"
49
+ end
50
+
51
+ def ios
52
+ platform == "ios"
53
+ end
52
54
  end
@@ -15,10 +15,6 @@ class Screenshot
15
15
  setup
16
16
  end
17
17
 
18
- def android
19
- platform == "android"
20
- end
21
-
22
18
  def screenshot
23
19
  puts "Saving to #{driver.outdir}/#{driver.name}.png"
24
20
  driver.screenshot driver.name
@@ -27,6 +23,10 @@ class Screenshot
27
23
 
28
24
  private
29
25
 
26
+ def android
27
+ platform == "android"
28
+ end
29
+
30
30
  def setup
31
31
  driver.clear_files
32
32
  end
@@ -82,7 +82,7 @@ class SimpleDaemon
82
82
  raise 'Second fork failed' if (pid = fork) == -1
83
83
  exit unless pid.nil?
84
84
  kill_pid
85
- @file = Tempfile.new
85
+ @file = Tempfile.new("flick-temp")
86
86
  @file.write Process.pid
87
87
  @file.rewind
88
88
  unless safe
@@ -115,9 +115,9 @@ class SimpleDaemon
115
115
  rescue TypeError
116
116
  $stdout.puts "#{pidfile} was empty: TypeError"
117
117
  rescue Errno::ENOENT
118
- #$stdout.puts "#{pidfile} did not exist: Errno::ENOENT"
118
+ $stdout.puts "#{pidfile} did not exist: Errno::ENOENT"
119
119
  rescue Errno::ESRCH
120
- #$stdout.puts "The process #{opid} did not exist: Errno::ESRCH"
120
+ $stdout.puts "The process #{opid} did not exist: Errno::ESRCH"
121
121
  rescue Errno::EPERM
122
122
  raise "Lack of privileges to manage the process #{opid}: Errno::EPERM"
123
123
  rescue ::Exception => e
data/lib/flick/system.rb CHANGED
@@ -7,10 +7,8 @@ module Flick
7
7
  Dir.mkdir dir_name unless File.exists? dir_name
8
8
  end
9
9
 
10
- def self.clean_system_dir dir_name, udid
11
- Dir.glob("#{dir_name}/*#{udid}*").each do |file|
12
- File.delete file
13
- end
10
+ def self.clean_system_dir dir_name
11
+ Dir.glob("#{dir_name}/*").each { |file| File.delete file }
14
12
  end
15
13
 
16
14
  def self.find_pid string
@@ -36,6 +34,10 @@ module Flick
36
34
  def self.kill_process type, udid
37
35
  pids = self.find_pid "#{type}-#{udid}"
38
36
  self.kill_pids pids
37
+ if type == "video"
38
+ pid = `pgrep -f #{udid}`.to_i
39
+ `kill #{pid}` unless pid.zero?
40
+ end
39
41
  end
40
42
 
41
43
  def self.kill string
data/lib/flick/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Flick
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/lib/flick/video.rb CHANGED
@@ -21,31 +21,24 @@ class Video
21
21
  self.format = options[:format]
22
22
  end
23
23
 
24
- def android
25
- platform == "android"
26
- end
27
-
28
- def ios
29
- platform == "ios"
30
- end
31
-
32
24
  def run
33
25
  self.send(action)
34
26
  end
35
27
 
36
28
  def start
37
29
  driver.clear_files
38
- puts "\nStarting Recoder!!!"
39
30
  if driver.recordable?
31
+ Flick::Checker.system_dependency "mp4box"
40
32
  if extended
41
- puts "In extended mode."
42
- Flick::Checker.system_dependency "mp4box"
33
+ puts "Starting Recorder In Extended Mode.\n"
43
34
  loop_record
44
35
  else
36
+ puts "Starting Recorder In Normal Mode.\nRecorder will automatically stop after 180 seconds...\n"
45
37
  start_record
46
38
  end
47
39
  else
48
40
  Flick::Checker.system_dependency "ffmpeg"
41
+ puts "Starting Screenshot Recorder...\n"
49
42
  start_screenshot_record
50
43
  end
51
44
  end
@@ -63,12 +56,20 @@ class Video
63
56
 
64
57
  private
65
58
 
59
+ def android
60
+ platform == "android"
61
+ end
62
+
63
+ def ios
64
+ platform == "ios"
65
+ end
66
+
66
67
  def start_record
67
68
  Flick::System.kill_process "video", udid
68
69
  $0 = "flick-video-#{udid}"
69
70
  SimpleDaemon.daemonize!
70
71
  command = -> do
71
- driver.screenrecord "video-#{udid}-single"
72
+ driver.screenrecord "video-single"
72
73
  end
73
74
  command.call
74
75
  end
@@ -81,7 +82,7 @@ class Video
81
82
  count = "%03d" % 1
82
83
  loop do
83
84
  unless Flick::System.process_running? "#{udid}-"
84
- driver.screenrecord "video-#{udid}-#{count}"
85
+ driver.screenrecord "video-#{count}"
85
86
  count.next!
86
87
  end
87
88
  end
@@ -90,12 +91,15 @@ class Video
90
91
  end
91
92
 
92
93
  def stop_record
93
- Flick::System.kill_process "video", udid
94
+ Flick::System.kill_process "video", udid #kills recording
94
95
  sleep 5 #wait for video process to finish
95
96
  driver.pull_files "video"
96
- files = Dir.glob("#{driver.flick_dir}/video-#{udid}*.mp4")
97
- return if files.empty?
98
- files.each { |file| system("mp4box -cat #{file} #{driver.flick_dir}/#{driver.name}.mp4") }
97
+ files = Dir.glob("#{driver.flick_dir}/video*.mp4")
98
+ if files.empty?
99
+ puts "\nError! No video files found in #{driver.flick_dir}\n".red
100
+ return
101
+ end
102
+ files.each { |file| system("mp4box -cat #{file} #{driver.flick_dir}/#{driver.name}.mp4") } #renames video-single to udid or name if given...
99
103
  puts "Saving to #{driver.outdir}/#{driver.name}.#{format}"
100
104
  if format == "gif"
101
105
  gif
@@ -113,7 +117,7 @@ class Video
113
117
  count = "%03d" % 1
114
118
  loop do
115
119
  if count.to_i <= image_count
116
- driver.screenshot "screenshot-#{udid}-#{count}"
120
+ driver.screenshot "screenshot-#{count}"
117
121
  count.next!; sleep seconds
118
122
  else
119
123
  stop_screenshot_recording
@@ -126,8 +130,9 @@ class Video
126
130
 
127
131
  def stop_screenshot_recording
128
132
  driver.pull_files "screenshot" if android
129
- puts "Saving to #{driver.outdir}/#{driver.name}.#{format}"
130
133
  self.send(format)
134
+ Flick::System.kill_process "screenshot", udid
135
+ puts "Saving to #{driver.outdir}/#{driver.name}.#{format}"
131
136
  end
132
137
 
133
138
  def gif
@@ -140,13 +145,21 @@ class Video
140
145
  File.rename "#{driver.flick_dir}/#{driver.name}.mp4", "#{driver.outdir}/#{driver.name}.mp4" unless format == "gif"
141
146
  end
142
147
 
148
+ def wait_for_file file
149
+ start = Time.now
150
+ until File.exists? file
151
+ sleep 1; break if Time.now - start > 30
152
+ end
153
+ end
154
+
143
155
  def convert_images_to_mp4
144
156
  remove_zero_byte_images
145
- %x(ffmpeg -loglevel quiet -framerate 1 -pattern_type glob -i '#{driver.flick_dir}/screenshot-#{udid}*.png' -c:v libx264 -pix_fmt yuv420p #{driver.flick_dir}/#{driver.name}.mp4)
157
+ %x(ffmpeg -loglevel quiet -framerate 1 -pattern_type glob -i '#{driver.flick_dir}/screenshot*.png' -c:v libx264 -pix_fmt yuv420p #{driver.flick_dir}/#{driver.name}.mp4)
158
+ wait_for_file "#{driver.flick_dir}/#{driver.name}.mp4"
146
159
  end
147
160
 
148
161
  def remove_zero_byte_images
149
- Dir.glob("#{driver.flick_dir}/screenshot-#{udid}*.png").each do |f|
162
+ Dir.glob("#{driver.flick_dir}/screenshot*.png").each do |f|
150
163
  File.delete f if File.zero? f
151
164
  end
152
165
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-10 00:00:00.000000000 Z
11
+ date: 2016-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,14 +84,14 @@ dependencies:
84
84
  requirements:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
- version: 0.7.7
87
+ version: 0.8.1
88
88
  type: :runtime
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: 0.7.7
94
+ version: 0.8.1
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: commander
97
97
  requirement: !ruby/object:Gem::Requirement
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
273
273
  version: '0'
274
274
  requirements: []
275
275
  rubyforge_project:
276
- rubygems_version: 2.5.2
276
+ rubygems_version: 2.5.1
277
277
  signing_key:
278
278
  specification_version: 4
279
279
  summary: A CLI to capture screenshots, video, logs, and device information for Android