summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimportd
diff options
context:
space:
mode:
Diffstat (limited to 'src/helsinki.at/rhimportd')
-rw-r--r--src/helsinki.at/rhimportd/ctrlTelnet.go29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/helsinki.at/rhimportd/ctrlTelnet.go b/src/helsinki.at/rhimportd/ctrlTelnet.go
index 38ee5c0..a329f59 100644
--- a/src/helsinki.at/rhimportd/ctrlTelnet.go
+++ b/src/helsinki.at/rhimportd/ctrlTelnet.go
@@ -29,6 +29,7 @@ import (
"fmt"
"helsinki.at/rhimport"
"net"
+ "net/http"
"strconv"
"strings"
)
@@ -239,10 +240,32 @@ func (c *TelnetClient) handle_cmd_show(args []string) {
}
func (c *TelnetClient) handle_cmd_run(args []string) {
- if c.ctx != nil {
- c.say("running args: %v", args)
- } else {
+ if c.ctx == nil {
c.say("context is empty please set at least one option")
+ return
+ }
+
+ if err := c.ctx.SanityCheck(); err != nil {
+ c.say("sanity check for import context returned: %s", err)
+ return
+ }
+
+ c.say("fetching file from '%s'", c.ctx.SourceUri)
+ if err := rhimport.FetchFile(c.ctx); err != nil {
+ c.say("fetch file error: %s", err)
+ return
+ }
+
+ c.say("importing file '%s'", c.ctx.SourceFile)
+ if result, err := rhimport.ImportFile(c.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)
+ } else {
+ c.say("Fileimport has failed (Cart/Cut %d/%d)", result.Cart, result.Cut)
+ }
}
}