vmcu 0.3.18 → 0.3.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -152,10 +152,10 @@ module VMC::Cli::Command
152
152
  require 'win32/registry'
153
153
  reg_targets = load_registry_targets
154
154
  rescue LoadError
155
- err "Unable not import data from Windows Registry"
155
+ err "Unable to import data from Windows Registry"
156
156
  exit 1
157
157
  rescue
158
- err "Unable not import data from Windows Registry"
158
+ err "Unable to import data from Windows Registry"
159
159
  exit 1
160
160
  end
161
161
 
@@ -50,13 +50,14 @@ module VMC::Cli
50
50
  5.times do
51
51
  begin
52
52
  results = @telnet_client.login("Name"=>auth_info["username"],
53
- "Password"=>auth_info["password"]) {|line|
54
- if line =~ /[$%#>] \z/n
55
- prompt = line
56
- elsif line =~ /Login failed/
57
- err_msg = line
58
- end
59
- }
53
+ "Password"=>auth_info["password"])
54
+ lines = results.split("\n")
55
+ last_line = lines.pop
56
+ if last_line =~ /[$%#>] \z/n
57
+ prompt = last_line
58
+ elsif last_line =~ /Login failed/
59
+ err_msg = last_line
60
+ end
60
61
  break
61
62
  rescue TimeoutError
62
63
  sleep 1
@@ -104,29 +105,31 @@ module VMC::Cli
104
105
  end
105
106
 
106
107
  def readline_with_history(prompt)
107
- line = Readline.readline(prompt, true)
108
- return '' if line.nil?
109
- #Don't keep blank or repeat commands in history
110
- if line =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == line
111
- Readline::HISTORY.pop
112
- end
108
+ line = Readline::readline(prompt)
109
+ return nil if line == nil || line == 'quit' || line == 'exit'
110
+ Readline::HISTORY.push(line) if not line =~ /^\s*$/ and Readline::HISTORY.to_a[-1] != line
113
111
  line
114
112
  end
115
113
 
116
114
  def run_console(prompt)
117
- while(cmd = readline_with_history(prompt))
118
- if(cmd == "exit" || cmd == "quit")
119
- #TimeoutError expected, as exit doesn't return anything
120
- @telnet_client.cmd("String"=>cmd,"Timeout"=>1) rescue TimeoutError
121
- close_console
115
+ prev = trap("INT") { |x| exit_console; prev.call(x); exit }
116
+ prev = trap("TERM") { |x| exit_console; prev.call(x); exit }
117
+ loop do
118
+ cmd = readline_with_history(prompt)
119
+ if(cmd == nil)
120
+ exit_console
122
121
  break
123
122
  end
124
- if !cmd.empty?
125
- prompt = send_console_command_display_results(cmd, prompt)
126
- end
123
+ prompt = send_console_command_display_results(cmd, prompt)
127
124
  end
128
125
  end
129
126
 
127
+ def exit_console
128
+ #TimeoutError expected, as exit doesn't return anything
129
+ @telnet_client.cmd("String"=>"exit","Timeout"=>1) rescue TimeoutError
130
+ close_console
131
+ end
132
+
130
133
  def send_console_command_display_results(cmd, prompt)
131
134
  begin
132
135
  lines = send_console_command cmd
@@ -19,7 +19,8 @@ module VMC::Cli
19
19
  'WSGI' => ['wsgi', { :mem => '64M', :description => 'Python WSGI Application'}],
20
20
  'Django' => ['django', { :mem => '128M', :description => 'Python Django Application'}],
21
21
  'dotNet' => ['dotNet', { :mem => '128M', :description => '.Net Web Application'}],
22
- 'Rack' => ['rack', { :mem => '128M', :description => 'Rack Application'}]
22
+ 'Rack' => ['rack', { :mem => '128M', :description => 'Rack Application'}],
23
+ 'Play' => ['play', { :mem => '256M', :description => 'Play Framework Application'}]
23
24
  }
24
25
 
25
26
  class << self
@@ -54,6 +55,8 @@ module VMC::Cli
54
55
  if !File.directory? path
55
56
  if path.end_with?('.war')
56
57
  return detect_framework_from_war path
58
+ elsif path.end_with?('.zip')
59
+ return detect_framework_from_zip path, available_frameworks
57
60
  elsif available_frameworks.include?(["standalone"])
58
61
  return Framework.lookup('Standalone')
59
62
  else
@@ -109,6 +112,7 @@ module VMC::Cli
109
112
  # Python
110
113
  elsif !Dir.glob('wsgi.py').empty?
111
114
  return Framework.lookup('WSGI')
115
+
112
116
  # .Net
113
117
  elsif !Dir.glob('web.config').empty?
114
118
  return Framework.lookup('dotNet')
@@ -118,6 +122,11 @@ module VMC::Cli
118
122
  if File.exist?('server.js') || File.exist?('app.js') || File.exist?('index.js') || File.exist?('main.js')
119
123
  return Framework.lookup('Node')
120
124
  end
125
+
126
+ # Play or Standalone Apps
127
+ elsif Dir.glob('*.zip').first
128
+ zip_file = Dir.glob('*.zip').first
129
+ return detect_framework_from_zip zip_file, available_frameworks
121
130
  end
122
131
 
123
132
  # Default to Standalone if no other match was made
@@ -125,7 +134,6 @@ module VMC::Cli
125
134
  end
126
135
  end
127
136
 
128
- private
129
137
  def detect_framework_from_war(war_file=nil)
130
138
  if war_file
131
139
  contents = ZipUtil.entry_lines(war_file)
@@ -149,6 +157,19 @@ module VMC::Cli
149
157
  return Framework.lookup('JavaWeb')
150
158
  end
151
159
  end
160
+
161
+ def detect_framework_from_zip(zip_file, available_frameworks)
162
+ contents = ZipUtil.entry_lines(zip_file)
163
+ detect_framework_from_zip_contents(contents, available_frameworks)
164
+ end
165
+
166
+ def detect_framework_from_zip_contents(contents, available_frameworks)
167
+ if available_frameworks.include?(["play"]) && contents =~ /lib\/play\..*\.jar/
168
+ return Framework.lookup('Play')
169
+ elsif available_frameworks.include?(["standalone"])
170
+ return Framework.lookup('Standalone')
171
+ end
172
+ end
152
173
  end
153
174
 
154
175
  attr_reader :name, :description, :console
@@ -2,6 +2,6 @@ module VMC
2
2
  module Cli
3
3
  # This version number is used as the RubyGem release version.
4
4
  # The internal VMC version number is VMC::VERSION.
5
- VERSION = '0.3.18'
5
+ VERSION = '0.3.19'
6
6
  end
7
7
  end
@@ -492,6 +492,11 @@ class VMC::Client
492
492
  headers['PROXY-USER'] = @proxy if @proxy
493
493
  headers['CloudTeam'] = @cloud_team if @cloud_team
494
494
  headers['ProxyRealm'] = @proxy_realm if @proxy_realm
495
+
496
+ if @via_uhuru_cloud && path.index("..") != 0 && @cloud_team == nil
497
+ raise TargetError, "Cloud team is not set. Use `vmcu cloud-team` to set the cloud team."
498
+ end
499
+
495
500
  path = "cf/" + path if @via_uhuru_cloud
496
501
 
497
502
  if content_type
@@ -508,6 +513,7 @@ class VMC::Client
508
513
  if request_failed?(status)
509
514
  # FIXME, old cc returned 400 on not found for file access
510
515
  err = (status == 404 || status == 400) ? NotFound : TargetError
516
+ err = AuthError if @via_uhuru_cloud && status == 401
511
517
  raise err, parse_error_message(status, body)
512
518
  else
513
519
  return status, body, response_headers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmcu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.18
4
+ version: 0.3.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-09 00:00:00.000000000 Z
12
+ date: 2012-05-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_pure
@@ -135,6 +135,22 @@ dependencies:
135
135
  - - ~>
136
136
  - !ruby/object:Gem::Version
137
137
  version: 2.1.0
138
+ - !ruby/object:Gem::Dependency
139
+ name: rb-readline
140
+ requirement: !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: 0.4.2
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ~>
152
+ - !ruby/object:Gem::Version
153
+ version: 0.4.2
138
154
  - !ruby/object:Gem::Dependency
139
155
  name: rake
140
156
  requirement: !ruby/object:Gem::Requirement