headless 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,8 +1,14 @@
1
+ ## 0.2.2 (2011-09-01)
2
+
3
+ * improve detection of ffmpeg process (from https://github.com/alanshields/headless)
4
+
1
5
  ## 0.2.1 (2011-08-26)
6
+
2
7
  * added ability to capture screenshots (from https://github.com/iafonov/headless)
3
8
  * added ability to capture video (from https://github.com/iafonov/headless)
4
9
  * fixed issue with stray pidfile
5
10
 
6
11
  ## 0.1.0 (2010-08-15)
12
+
7
13
  * introduced options
8
14
  * make it possible to change virtual screen dimensions and pixel depth
data/headless.gemspec CHANGED
@@ -3,7 +3,7 @@ spec = Gem::Specification.new do |s|
3
3
  s.email = 'leonid@shevtsov.me'
4
4
 
5
5
  s.name = 'headless'
6
- s.version = '0.2.1'
6
+ s.version = '0.2.2'
7
7
  s.summary = 'Ruby headless display interface'
8
8
 
9
9
  s.description = <<-EOF
@@ -16,7 +16,18 @@ class Headless
16
16
 
17
17
  def self.read_pid(pid_filename)
18
18
  pid = (File.read(pid_filename) rescue "").strip.to_i
19
- pid == 0 ? nil : pid
19
+ pid = nil if pid.zero?
20
+
21
+ if pid
22
+ begin
23
+ Process.kill(0, pid)
24
+ pid
25
+ rescue Errno::ESRCH
26
+ nil
27
+ end
28
+ else
29
+ nil
30
+ end
20
31
  end
21
32
 
22
33
  def self.fork_process(command, pid_filename, log_filename='/dev/null')
@@ -16,25 +16,28 @@ class Headless
16
16
  end
17
17
 
18
18
  def capture_running?
19
- !!@capture_running
19
+ CliUtil.read_pid @pid_file_path
20
20
  end
21
21
 
22
22
  def start_capture
23
23
  CliUtil.fork_process("#{CliUtil.path_to('ffmpeg')} -y -r 30 -g 600 -s #{@dimensions} -f x11grab -i :#{@display} -vcodec qtrle #{@tmp_file_path}", @pid_file_path, @log_file_path)
24
- @capture_running = true
25
24
  at_exit do
26
- stop_and_discard if capture_running?
25
+ stop_and_discard
27
26
  end
28
27
  end
29
28
 
30
29
  def stop_and_save(path)
31
- @capture_running = false
32
30
  CliUtil.kill_process(@pid_file_path, :wait => true)
33
- FileUtils.mv(@tmp_file_path, path)
31
+ if File.exists? @tmp_file_path
32
+ begin
33
+ FileUtils.mv(@tmp_file_path, path)
34
+ rescue Errno::EINVAL
35
+ nil
36
+ end
37
+ end
34
38
  end
35
39
 
36
40
  def stop_and_discard
37
- @capture_running = false
38
41
  CliUtil.kill_process(@pid_file_path, :wait => true)
39
42
  begin
40
43
  FileUtils.rm(@tmp_file_path)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: headless
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Leonid Shevtsov
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-26 00:00:00 +03:00
18
+ date: 2011-09-01 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency