Module: Flick::System

Includes:
Sys
Defined in:
lib/flick/system.rb

Class Method Summary collapse

Class Method Details

.clean_system_dir(dir_name, udid) ⇒ Object



10
11
12
13
14
# File 'lib/flick/system.rb', line 10

def self.clean_system_dir dir_name, udid
  Dir.glob("#{dir_name}/*#{udid}*").each do |file|
    File.delete file
  end
end

.find_pid(string) ⇒ Object



16
17
18
19
# File 'lib/flick/system.rb', line 16

def self.find_pid string
  processes = ProcTable.ps.find_all { |x| x.cmdline.include? string }
  processes.map { |p| p.pid } rescue []
end

.kill(string) ⇒ Object



41
42
43
44
# File 'lib/flick/system.rb', line 41

def self.kill string
  pids = self.find_pid string
  self.kill_pids pids
end

.kill_pids(pid_array) ⇒ Object



21
22
23
24
# File 'lib/flick/system.rb', line 21

def self.kill_pids pid_array
  return if pid_array.empty?
  pid_array.each { |p| Process.kill 'SIGKILL', p }
end

.kill_process(type, udid) ⇒ Object



36
37
38
39
# File 'lib/flick/system.rb', line 36

def self.kill_process type, udid
  pids = self.find_pid "#{type}-#{udid}"
  self.kill_pids pids
end

.process_running?(string) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
# File 'lib/flick/system.rb', line 26

def self.process_running? string
  pid = self.find_pid string
  unless pid.empty?
    puts "PROCESSING IS RUNNING!!!"
    true
  else
    false
  end
end

.setup_system_dir(dir_name) ⇒ Object



6
7
8
# File 'lib/flick/system.rb', line 6

def self.setup_system_dir dir_name
  Dir.mkdir dir_name unless File.exists? dir_name
end

.video_length(file) ⇒ Object



46
47
48
# File 'lib/flick/system.rb', line 46

def self.video_length file
  (`ffmpeg -i #{file} 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//`).strip
end