flick 0.3.2 → 0.3.5

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: 8fefe51010559fb70ada5f8286e5136f5b9aca04
4
- data.tar.gz: 8e97d55ae591cfe30d9c94c52c4de2f7fb40cf9c
3
+ metadata.gz: 60c1f971ea573c80a3728c5b6473637edc635510
4
+ data.tar.gz: 38a0fc9d7c3b996a44d3721262ee020a40745c27
5
5
  SHA512:
6
- metadata.gz: d4cf40f34b70b122f25d6422b61e5d0032c28d2a5784fd72cee8cdf0a76f4bdc98851b870209687adb19af27a9b7895bd935c132c4abc5bc2c2f5817bd63d813
7
- data.tar.gz: a6533405fc53ce22ec840faee7fd44d11f3ce3dc52aa223e13bfaa03d4bcfd84b4e86c88d76f4dfef9d740faabdb76bbbee25dd971f023d5977af6024971db7f
6
+ metadata.gz: 3c001315844ae3126cbb92d6d786522d6d07d7335021dd842ac915fefae80425f8f082e502fa532d0c4103ad4125e5b1dc2b26a5702a0753cc8a6b10afaaccbd
7
+ data.tar.gz: 4cd4aa8fe85f50196d59190f13f75e4ff9e9179b45ce90450427e479ca132403e823538c75cdda4c295589a8b7668ea8509485a57a98c065bb9386448a2f3bdc
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # FLICK
2
- A CLI to capture screenshots, video, logs, and device information for Android (Devices & Emulators) and iOS (Devices).
2
+ A CLI to capture screenshots, video, logs, device info and device vitals(memory, cpu) for Android (Devices & Emulators) and iOS (Devices).
3
3
 
4
4
  <img src="https://www.dropbox.com/s/o49et3fhncu3l4v/animacii_09.gif?raw=1" width="600">
5
5
 
@@ -111,6 +111,9 @@ Usage:
111
111
  $ flick manager -a install -p (ios or android) -f ~/myApp/my-awesome-app.apk or .app
112
112
  $ flick maanger -a uninstall -p (ios or android) -n com.package.name
113
113
 
114
+ `$ flick vitals --help`
115
+ $ flick vitals -n com.package.name
116
+
114
117
  ##Demo
115
118
  <img src="https://www.dropbox.com/s/9be37gc1c2dlxa6/flick-demo.gif?raw=1" width="600">
116
119
 
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.3.2'
5
+ program :version, '0.3.5'
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|
@@ -100,4 +100,17 @@ command :manager do |c|
100
100
 
101
101
  Manager.new(options.default).run
102
102
  end
103
+
104
+ command :vitals do |c|
105
+ c.syntax = 'flick vitals [options]'
106
+ c.summary = 'Android Only! Get apps and device vitals - App Memory Used, App CPU %. System Stats: (User, System, IQW, IRQ)'
107
+ c.description = c.summary
108
+ c.example 'description', "flick vitals -p android -n com.viber"
109
+ c.option '-p', '--platform PLATFORM', String, 'Set platform: android or ios'
110
+ c.option '-n', '--name NAME', String, 'Set the package name.'
111
+ c.action do |args, options|
112
+
113
+ Vitals.new(options.default).vitals
114
+ end
115
+ end
103
116
  end
data/flick.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = ["flick"]
26
26
  spec.require_paths = ["lib"]
27
27
 
28
- spec.add_development_dependency "bundler", "~> 1.10"
28
+ spec.add_development_dependency "bundler", "~> 1.9"
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'
@@ -37,4 +37,5 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "os", "~> 0.9.6"
38
38
  spec.add_dependency "sys-proctable", '~> 1.1', '>= 1.1.1'
39
39
  spec.add_dependency "apktools", '~> 0.7.1', '>= 0.7.1'
40
+ spec.add_dependency "ffi"
40
41
  end
data/lib/flick.rb CHANGED
@@ -18,4 +18,5 @@ require_relative "./flick/screenshot"
18
18
  require_relative "./flick/simple_daemon"
19
19
  require_relative "./flick/system"
20
20
  require_relative "./flick/video"
21
- require_relative "./flick/manager"
21
+ require_relative "./flick/manager"
22
+ require_relative "./flick/vitals"
data/lib/flick/android.rb CHANGED
@@ -30,7 +30,7 @@ module Flick
30
30
  end
31
31
 
32
32
  def clear_files
33
- Flick::System.clean_system_dir flick_dir
33
+ Flick::System.clean_system_dir flick_dir, udid
34
34
  %x(adb -s #{udid} shell rm '#{dir_name}/*')
35
35
  end
36
36
 
@@ -68,7 +68,35 @@ module Flick
68
68
  end
69
69
  hash
70
70
  end
71
+
72
+ def system_stats
73
+ x = %x(adb shell top -n 1 -d 1 | grep System).split(",")
74
+ user = x.find { |x| x.include? "User" }.match(/User (.*)%/)[1].to_i
75
+ sys = x.find { |x| x.include? "System" }.match(/System (.*)%/)[1].to_i
76
+ iow = x.find { |x| x.include? "IOW" }.match(/IOW (.*)%/)[1].to_i
77
+ irq = x.find { |x| x.include? "IRQ" }.match(/IRQ (.*)%/)[1].to_i
78
+ { user: user, system: sys, iow: iow, irq: irq }
79
+ end
80
+
81
+ def memory package
82
+ (%x(adb shell dumpsys meminfo | grep #{package} | awk '{print $1}').strip.split.last.to_i * 0.001).round(2)
83
+ end
71
84
 
85
+ def cpu package
86
+ %x(adb shell top -n 1 -d 1 | grep #{package} | awk '{print $3}').strip.chomp("%").to_i
87
+ end
88
+
89
+ def get_vitals package
90
+ if app_installed? package
91
+ stats = { app_stats: { memory_mb: memory(package), cpu_per: cpu(package) }, system_stats: system_stats }
92
+ puts stats
93
+ return stats
94
+ else
95
+ puts packages
96
+ puts "\n#{package} was not found on device #{udid}! Please choose one from above. e.g. #{packages.sample}\n".red
97
+ end
98
+ end
99
+
72
100
  def install app_path
73
101
  %x(adb -s #{udid} install -r #{app_path})
74
102
  end
@@ -113,6 +141,7 @@ module Flick
113
141
  end
114
142
 
115
143
  def log name
144
+ %x(adb -s #{udid} logcat -c)
116
145
  %x(adb -s #{udid} logcat -v long > #{outdir}/#{name}.log)
117
146
  end
118
147
 
@@ -153,7 +182,7 @@ module Flick
153
182
  return if files.empty?
154
183
  Parallel.map(files, in_threads: 10) do |file|
155
184
  pull_file file, flick_dir
156
- Flick::System.wait_for_file 10, "#{flick_dir}/#{file.split("/").last}"
185
+ #Flick::System.wait_for_file 10, "#{flick_dir}/#{file.split("/").last}"
157
186
  end
158
187
  end
159
188
  end
data/lib/flick/info.rb CHANGED
@@ -14,7 +14,7 @@ class Info
14
14
  end
15
15
  self.save = options[:save].to_b
16
16
  end
17
-
17
+
18
18
  def info
19
19
  ap driver.info
20
20
  if save
@@ -22,12 +22,14 @@ class Info
22
22
  save_device_data driver.info
23
23
  end
24
24
  end
25
-
25
+
26
26
  private
27
27
 
28
28
  def save_device_data info
29
+ file = "#{driver.outdir}/info-#{driver.name}.log"
30
+ File.delete file if File.exists? file
29
31
  info.each do |k,v|
30
- open("#{driver.outdir}/info-#{driver.name}.log", 'a') do |file|
32
+ open(file, 'a') do |file|
31
33
  file << "#{k}: #{v}\n"
32
34
  end
33
35
  end
data/lib/flick/ios.rb CHANGED
@@ -10,6 +10,7 @@ module Flick
10
10
  self.outdir = options.fetch(:outdir, Dir.pwd)
11
11
  self.specs = options.fetch(:specs, false)
12
12
  create_flick_dirs
13
+ is_paired?
13
14
  end
14
15
 
15
16
  def remove_bad_characters string
@@ -20,6 +21,15 @@ module Flick
20
21
  Flick::System.setup_system_dir "#{Dir.home}/.flick"
21
22
  Flick::System.setup_system_dir flick_dir
22
23
  end
24
+
25
+ def is_paired?
26
+ Flick::Checker.system_dependency "idevicepair"
27
+ unless %x(idevicepair -u #{udid} validate).split[0] == "SUCCESS:"
28
+ puts "\nUDID: #{udid} - Is not paired with your machine!".red
29
+ puts "Run: idevicepair -u <udid> pair\n".red
30
+ abort
31
+ end
32
+ end
23
33
 
24
34
  def devices
25
35
  Flick::Checker.system_dependency "idevice_id"
@@ -63,7 +73,7 @@ module Flick
63
73
  end
64
74
 
65
75
  def clear_files
66
- Flick::System.clean_system_dir flick_dir
76
+ Flick::System.clean_system_dir flick_dir, udid
67
77
  end
68
78
 
69
79
  def screenshot name
@@ -73,7 +83,9 @@ module Flick
73
83
 
74
84
  def log name
75
85
  Flick::Checker.system_dependency "idevicesyslog"
76
- %x(idevicesyslog -u #{udid} > #{outdir}/#{name}.log)
86
+ system("idevicesyslog -u #{udid} > #{outdir}/#{name}.log")
87
+ #file = File.open("#{outdir}/#{name}.log", 'a') { |f| f.puts "\n<<<<<<<<<<<<<<<<<<<<<<<<< FLICK LOG START >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" }
88
+ #file.close
77
89
  end
78
90
 
79
91
  def install app_path
@@ -45,6 +45,7 @@
45
45
  # grandchild, either the return value of the second fork (step 3) or the
46
46
  # value of getpid() after step 3.
47
47
  #
48
+
48
49
  class SimpleDaemon
49
50
 
50
51
  # In the directory where you want your daemon add a git submodule to
data/lib/flick/system.rb CHANGED
@@ -7,8 +7,10 @@ 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
11
- Dir.glob("#{dir_name}/*").each { |file| File.delete file }
10
+ def self.clean_system_dir dir_name, udid
11
+ Dir.glob("#{dir_name}/*#{udid}*").each do |file|
12
+ File.delete file
13
+ end
12
14
  end
13
15
 
14
16
  def self.find_pid string
@@ -34,24 +36,12 @@ module Flick
34
36
  def self.kill_process type, udid
35
37
  pids = self.find_pid "#{type}-#{udid}"
36
38
  self.kill_pids pids
37
- if type == "video"
38
- pid = `pgrep -f #{udid}`.to_i
39
- `kill #{pid}` unless pid.zero?
40
- end
41
39
  end
42
40
 
43
41
  def self.kill string
44
42
  pids = self.find_pid string
45
43
  self.kill_pids pids
46
44
  end
47
-
48
- def self.wait_for_file time, file
49
- start = Time.now
50
- until File.exists? file
51
- puts "Waiting for #{file} to exist..."
52
- sleep 1; break if Time.now - start > time
53
- end
54
- end
55
45
 
56
46
  def self.video_length file
57
47
  (`ffmpeg -i #{file} 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//`).strip
data/lib/flick/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Flick
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.5"
3
3
  end
data/lib/flick/video.rb CHANGED
@@ -21,24 +21,31 @@ 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
+
24
32
  def run
25
33
  self.send(action)
26
34
  end
27
35
 
28
36
  def start
29
37
  driver.clear_files
38
+ puts "\nStarting Recoder!!!"
30
39
  if driver.recordable?
31
- Flick::Checker.system_dependency "mp4box"
32
40
  if extended
33
- puts "Starting Recorder In Extended Mode.\n"
41
+ puts "In extended mode."
42
+ Flick::Checker.system_dependency "mp4box"
34
43
  loop_record
35
44
  else
36
- puts "Starting Recorder In Normal Mode.\nRecorder will automatically stop after 180 seconds...\n"
37
45
  start_record
38
46
  end
39
47
  else
40
48
  Flick::Checker.system_dependency "ffmpeg"
41
- puts "Starting Screenshot Recorder...\n"
42
49
  start_screenshot_record
43
50
  end
44
51
  end
@@ -56,20 +63,12 @@ class Video
56
63
 
57
64
  private
58
65
 
59
- def android
60
- platform == "android"
61
- end
62
-
63
- def ios
64
- platform == "ios"
65
- end
66
-
67
66
  def start_record
68
67
  Flick::System.kill_process "video", udid
69
68
  $0 = "flick-video-#{udid}"
70
69
  SimpleDaemon.daemonize!
71
70
  command = -> do
72
- driver.screenrecord "video-single"
71
+ driver.screenrecord "video-#{udid}-single"
73
72
  end
74
73
  command.call
75
74
  end
@@ -82,7 +81,7 @@ class Video
82
81
  count = "%03d" % 1
83
82
  loop do
84
83
  unless Flick::System.process_running? "#{udid}-"
85
- driver.screenrecord "video-#{count}"
84
+ driver.screenrecord "video-#{udid}-#{count}"
86
85
  count.next!
87
86
  end
88
87
  end
@@ -91,20 +90,17 @@ class Video
91
90
  end
92
91
 
93
92
  def stop_record
94
- Flick::System.kill_process "video", udid #kills recording
95
- sleep 5 #wait for video process to completely finish on device.
96
- driver.pull_files "video"
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...
93
+ Flick::System.kill_process "video", udid
94
+ sleep 5 #wait for video process to finish
95
+ 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") }
103
99
  puts "Saving to #{driver.outdir}/#{driver.name}.#{format}"
104
100
  if format == "gif"
105
101
  gif
106
102
  else
107
- File.rename "#{driver.flick_dir}/#{driver.name}.mp4", "#{driver.outdir}/#{driver.name}.mp4" #moves file from .flick to output dir.
103
+ File.rename "#{driver.flick_dir}/#{driver.name}.mp4", "#{driver.outdir}/#{driver.name}.mp4"
108
104
  end
109
105
  end
110
106
 
@@ -117,7 +113,7 @@ class Video
117
113
  count = "%03d" % 1
118
114
  loop do
119
115
  if count.to_i <= image_count
120
- driver.screenshot "screenshot-#{count}"
116
+ driver.screenshot "screenshot-#{udid}-#{count}"
121
117
  count.next!; sleep seconds
122
118
  else
123
119
  stop_screenshot_recording
@@ -130,9 +126,9 @@ class Video
130
126
 
131
127
  def stop_screenshot_recording
132
128
  driver.pull_files "screenshot" if android
133
- self.send(format)
134
129
  Flick::System.kill_process "screenshot", udid
135
130
  puts "Saving to #{driver.outdir}/#{driver.name}.#{format}"
131
+ self.send(format)
136
132
  end
137
133
 
138
134
  def gif
@@ -147,11 +143,12 @@ class Video
147
143
 
148
144
  def convert_images_to_mp4
149
145
  remove_zero_byte_images
150
- %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)
151
- Flick::System.wait_for_file 30, "#{driver.flick_dir}/#{driver.name}.mp4"
146
+ %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)
152
147
  end
153
148
 
154
149
  def remove_zero_byte_images
155
- Dir.glob("#{driver.flick_dir}/screenshot*.png").each { |f| File.delete f if File.zero? f }
150
+ Dir.glob("#{driver.flick_dir}/screenshot-#{udid}*.png").each do |f|
151
+ File.delete f if File.zero? f
152
+ end
156
153
  end
157
154
  end
@@ -0,0 +1,28 @@
1
+ class Vitals
2
+
3
+ attr_accessor :platform, :driver, :name
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.name = options[:name]
16
+ end
17
+
18
+ def vitals
19
+ if platform == "ios"
20
+ puts "\nAndroid only for now. If you know of a tool to get this info for iOS please let me know or add a PR :)\n".yellow; abort
21
+ end
22
+ if name.nil?
23
+ puts "Specify a Package Name. e.g. -n com.viber".red; abort
24
+ else
25
+ driver.get_vitals name
26
+ end
27
+ end
28
+ 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.3.2
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-02 00:00:00.000000000 Z
11
+ date: 2017-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '1.9'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
26
+ version: '1.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: 0.7.1
223
+ - !ruby/object:Gem::Dependency
224
+ name: ffi
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
223
237
  description: A CLI with helpful QA tools for iOS and Android from the command line
224
238
  email:
225
239
  - justin.ison@gmail.com
@@ -252,6 +266,7 @@ files:
252
266
  - lib/flick/system.rb
253
267
  - lib/flick/version.rb
254
268
  - lib/flick/video.rb
269
+ - lib/flick/vitals.rb
255
270
  homepage: https://github.com/isonic1/flick
256
271
  licenses:
257
272
  - MIT
@@ -273,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
273
288
  version: '0'
274
289
  requirements: []
275
290
  rubyforge_project:
276
- rubygems_version: 2.5.1
291
+ rubygems_version: 2.6.10
277
292
  signing_key:
278
293
  specification_version: 4
279
294
  summary: A CLI to capture screenshots, video, logs, and device information for Android