Module: SixUpdaterWeb
- Defined in:
- lib/six-updater-web/init.rb,
lib/six-updater-web/common.rb,
lib/six-updater-web/config/six-updater-web.rb
Overview
$stdout, $stderr = # File or String in Memory (any cleanup measures?) require ‘RubyGems’
Constant Summary collapse
- DEFAULT_PORT =
3000
- DEFAULT_IP =
"127.0.0.1"
- OPEN_BROWSER =
true
- SIX_HOST =
DEFAULT_IP
- SIX_PORT =
DEFAULT_PORT
- OLDLOCATION =
if defined?(TAR2RUBYSCRIPT) oldlocation else ENV['BASE_PATH'] ? ENV['BASE_PATH'] : Dir.pwd end
- SPECIAL =
unless ENV
ENV['BASE_PATH'] = OLDLOCATION end
true
- SIX_ADMIN =
true
- VERSION =
"0.15.2"
- COMPONENT =
"six-updater-web"
- LOCAL_URL =
"http://#{SIX_HOST == "0.0.0.0" ? DEFAULT_IP : SIX_HOST}:#{SIX_PORT}"
- BASE_PATH =
bpath
- TOOL_PATH =
File.join(BASE_PATH, 'tools')
- DATA_PATH =
COMPONENT)
File.join(File.exists?(File.join(BASE_PATH, "legacy.txt")) ? BASE_PATH : HOME_PATH, "six-updater")
Class Method Summary collapse
- .after_initialize ⇒ Object
- .initialize(config) ⇒ Object
- .logger ⇒ Object
- .prepare_data_path ⇒ Object
- .print_info ⇒ Object
- .run_program(exec, startpath, cl) ⇒ Object
- .stamp(time) ⇒ Object
Class Method Details
.after_initialize ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/six-updater-web/config/six-updater-web.rb', line 144 def after_initialize if defined?(OLDLOCATION && SPECIAL) # Update data in tables; nah, rather start warning users on main page? #Six::Dbmanager.check case RUBY_PLATFORM when /-mingw32$/, /-mswin32$/ return unless defined?(OPEN_BROWSER) Thread.new() do file_to_use = "#{LOCAL_URL}/main" sleep 4 system "start #{file_to_use}" end =begin arguments = nil directory = nil operation = "OPEN" show = nil #begin shell = WIN32OLE.new('Shell.Application') shell.ShellExecute(file_to_use, arguments, directory, operation, show) #rescue => e #logger.warn "Unable to open browser: ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}" #end =end end end end |
.initialize(config) ⇒ Object
131 132 133 134 135 |
# File 'lib/six-updater-web/config/six-updater-web.rb', line 131 def initialize(config) if defined?(OLDLOCATION) config.log_path = File.join(DATA_PATH, 'logs', 'six-updater-web.log') end end |
.logger ⇒ Object
122 123 124 |
# File 'lib/six-updater-web/config/six-updater-web.rb', line 122 def logger ActiveRecord::Base.logger end |
.prepare_data_path ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/six-updater-web/init.rb', line 34 def prepare_data_path # Arrange appdata! lf = File.join(DATA_PATH, "logs") FileUtils.mkdir_p(lf) unless File.directory?(lf) df = File.join(DATA_PATH, "db") FileUtils.mkdir_p(df) unless File.directory?(df) db = File.join(DATA_PATH, "db", "production.sqlite3") unless File.exists?(db) puts "Database Missing, creating and loading default schema and system data..." File.open(db, 'w') {|f| } Dir.chdir(File.dirname(__FILE__)) do system "ruby -rubygems \"_rake.rb\" db:migrate goldberg:migrate db:schema:dump sync:system" end #FileUtils.cp(File.join(BASE_PATH, "db", "production.sqlite3"), db) return true end false end |
.print_info ⇒ Object
137 138 139 140 141 142 |
# File 'lib/six-updater-web/config/six-updater-web.rb', line 137 def print_info puts "Six Updater Web (GUI) #{VERSION}, by Sickboy" puts "BASE: #{BASE_PATH}" puts "DATA: #{DATA_PATH}" puts "ARMA: #{DISTRO} PATH: #{ARMA_PATH}" end |
.run_program(exec, startpath, cl) ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/six-updater-web/config/six-updater-web.rb', line 173 def run_program(exec, startpath, cl) logger.info "Current Path: #{Dir.pwd}, BASE_PATH: #{BASE_PATH}, DATA_PATH: #{DATA_PATH}" logger.info "Starting with #{cl} from #{startpath}" # TODO: Cleanup startpath = "#{startpath}" begin case RUBY_PLATFORM when /-mingw32$/, /-mswin32$/ cl = "\"#{exec}\" #{cl}" cl = "/C #{cl}" logger.info "#{CMD_EXE} #{cl}" struct = Process.create( :app_name => CMD_EXE, :command_line => cl, :creation_flags => Process::DETACHED_PROCESS, :process_inherit => false, :thread_inherit => false, :cwd => startpath, :inherit => false #:environment => "" ) else Dir.chdir(startpath) do # TODO: Properly create seperate process like on windows.. or maybe this is fine just needs 2>&1 >> /dev/null ? # as logfiles deliver the feedback, or rather run integrated. However maybe when running in a desktop environment # maybe it's useful to open a new terminal window/tab .. p = Process.fork do logger.info "#{exec} #{cl}" system "#{exec} #{cl}" end end #logger.info "Unimplemented on current platform: #{RUBY_PLATFORM}" end rescue => e logger.info "WARNING: Something went wrong starting the app" logger.info "#{e.class}: #{e.} #{e.backtrace.join("\n")}" end end |
.stamp(time) ⇒ Object
126 127 128 129 |
# File 'lib/six-updater-web/config/six-updater-web.rb', line 126 def stamp(time) (Time.now - time).to_s[/(.*\..?.?.?)/] $1 end |