Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
debomatic-webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
debomatic-webui-admins
debomatic-webui
Commits
3d3ed940
Commit
3d3ed940
authored
Mar 13, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handling errors and carry out via socket
parent
9f66c106
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
21 deletions
+52
-21
debomatic-webui/lib/broadcaster.js
debomatic-webui/lib/broadcaster.js
+4
-1
debomatic-webui/lib/client.js
debomatic-webui/lib/client.js
+8
-6
debomatic-webui/lib/utils.js
debomatic-webui/lib/utils.js
+36
-12
debomatic-webui/public/javascripts/page_generic.js
debomatic-webui/public/javascripts/page_generic.js
+4
-2
No files found.
debomatic-webui/lib/broadcaster.js
View file @
3d3ed940
...
...
@@ -12,7 +12,10 @@ function __watch_build_status (socket, status) {
var
data
=
null
try
{
data
=
JSON
.
parse
(
new_content
)
}
catch
(
error
)
{
return
}
}
catch
(
err
)
{
utils
.
erros_handler
(
'
Broadcaster:__watch_build_status:JSON.parse(new_content) -
'
,
err
,
socket
)
return
}
if
(
data
.
status
==
config
.
status
.
package
.
building
)
{
status
.
packages
.
push
(
data
)
}
...
...
debomatic-webui/lib/client.js
View file @
3d3ed940
...
...
@@ -3,6 +3,8 @@ var fs = require('fs')
,
config
=
require
(
'
./config.js
'
)
,
utils
=
require
(
'
./utils.js
'
)
var
_e
=
config
.
events
.
client
function
__get_files_list_from_package
(
data
,
callback
)
{
package_path
=
utils
.
get_package_path
(
data
)
utils
.
get_files_list
(
package_path
,
false
,
function
(
files
)
{
...
...
@@ -108,9 +110,12 @@ function __send_distribution_packages (event_name, socket, data) {
}
function
__send_file
(
event_name
,
socket
,
data
)
{
file_path
=
utils
.
get_file_path
(
data
)
var
file_path
=
utils
.
get_file_path
(
data
)
fs
.
readFile
(
file_path
,
'
utf8
'
,
function
(
err
,
content
)
{
if
(
err
)
return
;
if
(
err
)
{
utils
.
errors_handler
(
'
client:__send_file
'
,
err
,
socket
)
return
}
data
.
file
.
orig_name
=
file_path
.
split
(
'
/
'
).
pop
()
data
.
file
.
content
=
content
data
.
file
.
path
=
file_path
.
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
...
...
@@ -119,8 +124,7 @@ function __send_file (event_name, socket, data) {
}
function
__handler_get_file
(
socket
,
data
)
{
var
_e
=
config
.
events
.
client
file_path
=
utils
.
get_file_path
(
data
)
var
file_path
=
utils
.
get_file_path
(
data
)
utils
.
watch_path_onsocket
(
_e
.
file_newcontent
,
socket
,
data
,
file_path
,
function
(
event_name
,
socket
,
data
)
{
data
.
file
.
content
=
null
socket
.
emit
(
event_name
,
data
)
...
...
@@ -132,8 +136,6 @@ function Client (socket) {
var
socket
=
socket
var
_e
=
config
.
events
.
client
this
.
start
=
function
()
{
// init send distributions and status
utils
.
get_files_list
(
config
.
debomatic
.
path
,
true
,
function
(
distros
)
{
...
...
debomatic-webui/lib/utils.js
View file @
3d3ed940
...
...
@@ -3,6 +3,14 @@ var path = require('path')
,
Tail
=
require
(
'
tail
'
).
Tail
,
config
=
require
(
'
./config.js
'
)
function
__errors_handler
(
from
,
err
,
socket
)
{
if
(
!
socket
)
from
=
"
NO SOCKET:
"
+
from
console
.
error
(
from
,
err
)
if
(
socket
)
socket
.
emit
(
config
.
events
.
error
,
err
.
message
)
}
function
__check_no_backward
(
backward_path
)
{
try
{
return
backward_path
.
indexOf
(
'
..
'
)
<
0
...
...
@@ -37,7 +45,7 @@ function __get_files_list(dir, onlyDirectories, callback) {
fs
.
readdir
(
dir
,
function
(
err
,
files
){
result
=
[];
if
(
err
)
{
console
.
error
(
err
);
__errors_handler
(
"
__get_files_list
"
,
err
)
return
;
}
files
.
forEach
(
function
(
f
)
{
...
...
@@ -54,7 +62,10 @@ function __get_files_list(dir, onlyDirectories, callback) {
result
.
push
(
f
);
}
}
}
catch
(
fs_error
)
{}
}
catch
(
fs_error
)
{
__errors_handler
(
"
__get_files_list:forEach
"
,
fs_err
)
return
}
});
callback
(
result
);
});
...
...
@@ -63,17 +74,19 @@ function __get_files_list(dir, onlyDirectories, callback) {
function
__watch_path_onsocket
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
name
=
"
watcher-
"
+
event_name
socket
.
get
(
name
,
function
(
err
,
watcher
)
{
if
(
watcher
)
{
try
{
watcher
.
unwatch
()
}
catch
(
errorWatchingDirectory
)
{
watcher
.
close
()
}
}
try
{
if
(
watcher
)
{
try
{
watcher
.
unwatch
()
}
catch
(
errorWatchingDirectory
)
{
watcher
.
close
()
}
}
fs
.
stat
(
watch_path
,
function
(
err
,
stats
)
{
if
(
err
)
if
(
err
)
{
utils
.
errors_handler
(
"
__watch_path_onsocket:fs.stat
"
,
err
,
socket
)
return
}
if
(
stats
.
isDirectory
())
{
watcher
=
fs
.
watch
(
watch_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
...
...
@@ -85,12 +98,20 @@ function __watch_path_onsocket(event_name, socket, data, watch_path, updater) {
watcher
.
on
(
'
line
'
,
function
(
new_content
)
{
data
.
file
.
new_content
=
new_content
+
'
\n
'
updater
(
event_name
,
socket
,
data
)
}).
on
(
'
error
'
,
function
(
err
)
{
watcher
.
unwatch
()
__errors_handler
(
"
__watch_path_onsocket.Tail <-
"
+
arguments
.
callee
.
caller
.
name
,
err
,
socket
)
return
})
}
socket
.
set
(
name
,
watcher
)
}
})
}
catch
(
err_watch
)
{
console
.
error
(
'
utils.__watch_path_onsocket
'
+
err_watch
)}
}
catch
(
err
)
{
__errors_handler
(
"
__watch_path_onsocket <-
"
+
arguments
.
callee
.
caller
.
name
,
err
,
socket
)
return
}
})
return
true
;
}
function
__generic_handler_watcher
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
{
...
...
@@ -126,6 +147,9 @@ utils = {
generic_handler_watcher
:
function
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
{
return
__generic_handler_watcher
(
event_name
,
socket
,
data
,
watch_path
,
callback
);
},
errors_handler
:
function
(
from
,
error
,
socket
)
{
return
__errors_handler
(
from
,
error
,
socket
)
}
}
module
.
exports
=
utils
debomatic-webui/public/javascripts/page_generic.js
View file @
3d3ed940
...
...
@@ -98,8 +98,6 @@ function Page_Generic()
distributions
.
set
(
socket_distributions
)
});
socket
.
on
(
'
error
'
,
function
(
socket_data_error
)
{
console
.
error
(
socket_data_error
)
});
socket
.
on
(
_e
.
client
.
status
,
function
(
packages_status
)
{
status
.
set
(
packages_status
)
})
...
...
@@ -107,5 +105,9 @@ function Page_Generic()
socket
.
on
(
_e
.
broadcast
.
status_update
,
function
(
package_status
)
{
status
.
update
(
package_status
)
})
socket
.
on
(
_e
.
error
,
function
(
error
)
{
console
.
error
(
error
)
})
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment