summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimportd/ctrlTelnet.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/helsinki.at/rhimportd/ctrlTelnet.go')
-rw-r--r--src/helsinki.at/rhimportd/ctrlTelnet.go41
1 files changed, 30 insertions, 11 deletions
diff --git a/src/helsinki.at/rhimportd/ctrlTelnet.go b/src/helsinki.at/rhimportd/ctrlTelnet.go
index eb3c607..65504f4 100644
--- a/src/helsinki.at/rhimportd/ctrlTelnet.go
+++ b/src/helsinki.at/rhimportd/ctrlTelnet.go
@@ -152,11 +152,23 @@ func (c *TelnetClient) handle_cmd_set(args []string) {
}
switch strings.ToLower(args[0]) {
case "username":
- c.ctx.UserName = args[1]
+ if args[1] == "\"\"" || args[1] == "''" {
+ c.ctx.UserName = ""
+ } else {
+ c.ctx.UserName = args[1]
+ }
case "password":
- c.ctx.Password = args[1]
+ if args[1] == "\"\"" || args[1] == "''" {
+ c.ctx.Password = ""
+ } else {
+ c.ctx.Password = args[1]
+ }
case "sourceuri":
- c.ctx.SourceUri = args[1]
+ if args[1] == "\"\"" || args[1] == "''" {
+ c.ctx.SourceUri = ""
+ } else {
+ c.ctx.SourceUri = args[1]
+ }
case "showid":
if id, err := strconv.ParseUint(args[1], 10, 32); err != nil {
c.say("invalid value (must be an positive integer)")
@@ -170,7 +182,11 @@ func (c *TelnetClient) handle_cmd_set(args []string) {
c.ctx.ClearShowCarts = val
}
case "groupname":
- c.ctx.GroupName = args[1]
+ if args[1] == "\"\"" || args[1] == "''" {
+ c.ctx.GroupName = ""
+ } else {
+ c.ctx.GroupName = args[1]
+ }
case "cart":
if cart, err := strconv.ParseUint(args[1], 10, 32); err != nil {
c.say("invalid value (must be an positive integer)")
@@ -263,22 +279,25 @@ func (c *TelnetClient) handle_cmd_run(args []string) {
}
c.say("fetching file from '%s'", ctx.SourceUri)
- if err := rhimport.FetchFile(&ctx); err != nil {
+ if fres, err := rhimport.FetchFile(&ctx); err != nil {
c.say("fetch file error: %s", err)
return
+ } else if fres.ResponseCode != http.StatusOK {
+ c.say("fetch file error: %s", fres.ErrorString)
+ return
}
c.say("importing file '%s'", ctx.SourceFile)
- if result, err := rhimport.ImportFile(&ctx); err != nil {
+ if ires, err := rhimport.ImportFile(&ctx); err != nil {
c.say("import file error: %s", err)
return
} else {
- if result.ResponseCode == http.StatusOK {
- c.say("File got succesfully imported into Cart/Cut %d/%d", result.Cart, result.Cut)
- rhl.Printf("File got succesfully imported into Cart/Cut %d/%d", result.Cart, result.Cut)
+ if ires.ResponseCode == http.StatusOK {
+ c.say("File got succesfully imported into Cart/Cut %d/%d", ires.Cart, ires.Cut)
+ rhl.Printf("File got succesfully imported into Cart/Cut %d/%d", ires.Cart, ires.Cut)
} else {
- c.say("Fileimport has failed (Cart/Cut %d/%d): %s", result.Cart, result.Cut, result.ErrorString)
- rhl.Printf("Fileimport has failed (Cart/Cut %d/%d): %s", result.Cart, result.Cut, result.ErrorString)
+ c.say("Fileimport has failed (Cart/Cut %d/%d): %s", ires.Cart, ires.Cut, ires.ErrorString)
+ rhl.Printf("Fileimport has failed (Cart/Cut %d/%d): %s", ires.Cart, ires.Cut, ires.ErrorString)
}
}
}