public
Description: Your friendly neighborhood nzb downloader
Homepage:
Clone URL: git://github.com/maddox/pyrot.git
Click here to lend your support to: pyrot and make a donation at www.pledgie.com !
pyrot / Rakefile
100755 110 lines (85 sloc) 3.504 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
require 'rubygems'
require 'yaml'
require 'lib/builder/builder'
 
namespace :pyrot do
  
  desc "Generate Pyrot Daemon Config File"
  task :generate_daemon_config do
 
    if ENV['env'] == "dev"
      puts "Starting pyrot in dev mode"
      postfix = "_dev"
    else
      puts "Starting pyrot in production mode"
      postfix = ""
    end
 
    raw_config = open(File.join(File.dirname(__FILE__), 'config', "pyrot#{postfix}.yml")).read
    PYROT_CONFIG = YAML.load(raw_config)
 
    config = open(File.join(File.dirname(__FILE__), 'lib', 'pyrot', "config#{postfix}.xml"), 'w+')
    xml = Builder::XmlMarkup.new(:target => config, :indent => 1)
    xml.instruct!
 
    xml.tag! 'nzb-config' do
 
      xml.tag! 'thread-count', PYROT_CONFIG['thread_count']
      xml.tag! 'bandwidth-limit', PYROT_CONFIG['bandwidth_limit']
      xml.tag! 'skip-pars', PYROT_CONFIG['skip_pars']
      xml.tag! 'store-by-group', PYROT_CONFIG['store_by_group']
 
      xml.usenet do
        xml.host PYROT_CONFIG['usenet']['host']
        xml.login PYROT_CONFIG['usenet']['login']
        xml.password PYROT_CONFIG['usenet']['password']
      end
 
      xml.newzbin do
        xml.login PYROT_CONFIG['newzbin']['login']
        xml.password PYROT_CONFIG['newzbin']['password']
      end
 
      xml.server do
        xml.port 1480
        xml.streamPort 1481
        xml.streamPath PYROT_CONFIG['post_scripts']['ipod_path']
        xml.login 'test'
        xml.password 'test'
      end
 
      xml.group :title => :Movies do
        xml.tag! 'save-directory', PYROT_CONFIG['movies']['save_directory']
        xml.tag! 'par-repair'
        xml.unrar
        xml.script do
          xml.command PYROT_CONFIG['movies']['script']
        end
      end
 
      xml.group :title => :TV do
        xml.tag! 'save-directory', PYROT_CONFIG['tv']['save_directory']
        xml.tag! 'par-repair'
        xml.unrar
        xml.script do
          xml.command PYROT_CONFIG['tv']['script']
        end
      end
    end
 
    config.close
  end
 
 
  desc "Start Pyrot"
  task :run=> :generate_daemon_config do
    postfix = ENV['env'] == "dev" ? "_dev" : ""
  
    puts "Starting Pyrot"
    puts
                mkdir "log" unless File.exist?("log")
    system "java -Djava.awt.headless=true -Dlog4j.configuration=file:#{File.join(File.dirname(__FILE__), 'lib', 'pyrot', 'log4j.properties')} -jar #{File.join(File.dirname(__FILE__), 'lib', 'pyrot', 'pyrot-client.jar')} #{File.join(File.dirname(__FILE__), 'lib', 'pyrot', "config#{postfix}.xml")}"
  end or raise "Failures"
 
  desc "Start Pyrot daemon"
  task :start => :generate_daemon_config do
    postfix = ENV['env'] == "dev" ? "_dev" : ""
   
    puts "Starting the Pyrot daemon"
    puts
mkdir "log" unless File.exist?("log")
    system "java -Djava.awt.headless=true -Dlog4j.configuration=file:#{File.join(File.dirname(__FILE__), 'lib', 'pyrot', 'log4j.properties')} -jar #{File.join(File.dirname(__FILE__), 'lib', 'pyrot', 'pyrot-client.jar')} #{File.join(File.dirname(__FILE__), 'lib', 'pyrot', "config#{postfix}.xml")} &> log/pyrot-startup.log & echo $! > #{File.join(File.dirname(__FILE__), 'log', 'pyrot.pid')} "
  end or raise "Failures"
 
  desc "Stop Pyrot daemon"
  task :stop do
    puts "Stopping the Pyrot daemon"
    puts
    pid = File.new(File.join(File.dirname(__FILE__), 'log', 'pyrot.pid'), 'r').readline
    system "kill #{pid}"
    
  end or raise "Failures"
 
 
  desc "Restart Pyrot daemon"
  task :restart => [:stop, :start] do
  end or raise "Failures"
  
end