navilocal 0.0.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/application/models/settings.rb +5 -0
- data/application/ui/navi/main_runner.rb +46 -44
- data/application/ui/navi/splash.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 428854cbf081cf3618d3bb45026080cc3b507627288bcbf50922a347d9f88256
|
4
|
+
data.tar.gz: 1f18f7e950fba484d35c38730c4cc21564825b362694e7bb1c2d3993dbeadaa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c889e499760a6e755c0dd8d69687cea89d8648ac6ef1705693038e62fa6c0cc7e8740e111f51ac4cb975acacc5ccee9d7eb03f250b860d842d7e7503dc23e0b
|
7
|
+
data.tar.gz: 19a4a6c6148114d1b4539a76dba44e6ce640e3135e75f3d3a3d7a58791bb95314f6a60e814a67d44d35f9b27a2311744ae2e471e0f40b05e0d3d293ff54294ef
|
@@ -9,6 +9,11 @@ module NaviClientInstaller
|
|
9
9
|
|
10
10
|
DEFAULT_STORAGE = File.expand_path File.join('~', '.navi')
|
11
11
|
|
12
|
+
SSO_URL = "https://signin.navihq.com"
|
13
|
+
GENERATE_CSV_URL = "https://api2.navihq.com/v2/generate_csv_input"
|
14
|
+
|
15
|
+
|
16
|
+
|
12
17
|
attr_accessor *PROPERTIES
|
13
18
|
|
14
19
|
def initialize(options = {})
|
@@ -50,11 +50,7 @@ module NaviClientInstaller
|
|
50
50
|
end
|
51
51
|
|
52
52
|
@refresh_btn.signal_connect 'clicked' do |button|
|
53
|
-
|
54
|
-
@logger.debug "Restarting the process"
|
55
|
-
@stop_btn.set_sensitive true
|
56
|
-
start
|
57
|
-
@notifier.label = "Restarting.."
|
53
|
+
restart_process
|
58
54
|
end
|
59
55
|
|
60
56
|
@window_ui.signal_connect("destroy") {|button|
|
@@ -76,16 +72,26 @@ module NaviClientInstaller
|
|
76
72
|
|
77
73
|
def terminate_worker_thread
|
78
74
|
stop_naviai
|
75
|
+
@imap&.disconnect unless @imap&.disconnected?
|
79
76
|
@worker_thread&.terminate if @worker_thread&.alive?
|
80
77
|
|
81
78
|
end
|
82
79
|
|
80
|
+
def restart_process terminate_worker = true
|
81
|
+
terminate_worker_thread if terminate_worker
|
82
|
+
@logger.debug "Restarting the process"
|
83
|
+
@notifier.label = "Restarting.."
|
84
|
+
@stop_btn.set_sensitive true
|
85
|
+
start
|
86
|
+
|
87
|
+
end
|
88
|
+
|
83
89
|
|
84
90
|
def start_fetching
|
85
91
|
|
86
92
|
env = "development"
|
87
|
-
sso_web_url =
|
88
|
-
gen_csv_url =
|
93
|
+
sso_web_url = NaviClientInstaller::Settings::SSO_URL
|
94
|
+
gen_csv_url = NaviClientInstaller::Settings::GENERATE_CSV_URL
|
89
95
|
|
90
96
|
@client = NaviClient::Local.new(sso_web_url, "local", gen_csv_url, true, env)
|
91
97
|
@client.set_token "Token: #{@token}##{@settings.username}"
|
@@ -98,34 +104,36 @@ module NaviClientInstaller
|
|
98
104
|
@client.setupLoggly("navi-client")
|
99
105
|
end
|
100
106
|
|
101
|
-
@logger.debug "Running the process..
|
107
|
+
@logger.debug "Running the process.."
|
102
108
|
@logger.debug "Connecting to imap server with your local config."
|
103
109
|
|
104
110
|
@notifier.label = "Configuring the system.."
|
105
|
-
|
111
|
+
begin
|
112
|
+
|
113
|
+
@imap = @client.imap_connection(@settings.provider, @settings.username, @settings.password, false)
|
114
|
+
|
115
|
+
if @client.errors.nil?
|
106
116
|
|
107
|
-
|
117
|
+
@logger.debug "Complete. OK..."
|
108
118
|
|
109
|
-
|
119
|
+
filenames = []
|
120
|
+
dateStarted = DateTime.now
|
121
|
+
@logger.debug "Syncing started at #{dateStarted}"
|
122
|
+
@client.logToLoggly({event:"EMAIL_SYNC_STARTED", env: env, storage: "local", email: @settings.username})
|
110
123
|
|
111
|
-
|
112
|
-
|
113
|
-
@logger.debug "Syncing started at #{dateStarted}"
|
114
|
-
@client.logToLoggly({event:"EMAIL_SYNC_STARTED", env: env, storage: "local", email: @settings.username})
|
124
|
+
sendEmailCompletedEvent = true
|
125
|
+
folder = "Inbox"
|
115
126
|
|
116
|
-
|
117
|
-
|
127
|
+
#this block of code is repeated. Need to change in navi_client gem for that
|
128
|
+
@imap.examine folder
|
129
|
+
total = @imap.uid_search(['ALL']).size
|
130
|
+
downloaded = @client.getMessageUUIds("#{@settings.download_path}#{@settings.username}/meta/").size
|
131
|
+
downloaded = downloaded - 2 if downloaded > 1
|
118
132
|
|
119
|
-
|
120
|
-
@imap.examine folder
|
121
|
-
total = @imap.uid_search(['ALL']).size
|
122
|
-
downloaded = @client.getMessageUUIds("#{@settings.download_path}#{@settings.username}/meta/").size
|
123
|
-
downloaded = downloaded - 2 if downloaded > 1
|
133
|
+
@email_indicator.label = "#{downloaded}/#{total}"
|
124
134
|
|
125
|
-
@email_indicator.label = "#{downloaded}/#{total}"
|
126
135
|
|
127
|
-
|
128
|
-
# start_naviai
|
136
|
+
# start_naviai
|
129
137
|
@notifier.label = "Checking for previous failures.."
|
130
138
|
|
131
139
|
start_naviai
|
@@ -181,15 +189,14 @@ module NaviClientInstaller
|
|
181
189
|
@notifier.label = "Waiting for the new emails.."
|
182
190
|
@client.idle_loop(@imap, ['UNSEEN'], folder, @settings.provider, @settings.username, @settings.password)
|
183
191
|
|
184
|
-
@imap.logout
|
185
|
-
@imap.disconnect
|
186
192
|
|
187
|
-
rescue => e
|
188
|
-
@logger.debug "#{e.message}"
|
189
|
-
end
|
190
193
|
|
191
|
-
|
192
|
-
|
194
|
+
else
|
195
|
+
@logger.debug "Failed to connect with your email. Please recheck the configuration."
|
196
|
+
end
|
197
|
+
rescue => e
|
198
|
+
@logger.debug "#{e.message}"
|
199
|
+
restart_process false
|
193
200
|
end
|
194
201
|
|
195
202
|
end
|
@@ -204,25 +211,20 @@ module NaviClientInstaller
|
|
204
211
|
end
|
205
212
|
|
206
213
|
def start_naviai
|
214
|
+
stop_naviai
|
207
215
|
navi_path = NaviClientInstaller::Settings::DEFAULT_STORAGE
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
File.open("#{navi_path}/bin/naviai_pid.tmp", 'w') { |file| file.write(pid) }
|
212
|
-
|
213
|
-
Process.detach(pid)
|
216
|
+
system("#{navi_path}/bin/naviai &")
|
217
|
+
sleep 1
|
214
218
|
end
|
215
219
|
|
216
220
|
def stop_naviai
|
217
221
|
# kill naviai process
|
218
|
-
|
222
|
+
naviPid = Integer(%x(lsof -i tcp:9090 | grep naviai | awk {'print $2'})) rescue false
|
219
223
|
begin
|
220
|
-
Process.kill('QUIT', File.read(navi_path).to_i)
|
221
|
-
|
222
|
-
# process exited normally
|
224
|
+
# Process.kill('QUIT', File.read(navi_path).to_i)
|
225
|
+
%x(kill -9 #{naviPid}) if naviPid
|
223
226
|
rescue
|
224
|
-
|
225
|
-
FileUtils.rm_f navi_path
|
227
|
+
@logger.debug "Could not stop navi ai." unless @logger.nil?
|
226
228
|
end
|
227
229
|
end
|
228
230
|
|
@@ -34,7 +34,7 @@ module NaviClientInstaller
|
|
34
34
|
def validate_email(email, pass)
|
35
35
|
# need to remove this hardcoded code
|
36
36
|
begin
|
37
|
-
HTTParty.post("
|
37
|
+
HTTParty.post(NaviClientInstaller::Settings::SSO_URL + "/oauth/token",
|
38
38
|
body: {
|
39
39
|
email: email, # get from sso_web application
|
40
40
|
password: pass,
|