diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-12-18 20:53:22 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-12-18 20:53:22 (GMT) |
commit | e4eaa2082ac00a8a44e4867fcc0c98e538e7f5b4 (patch) | |
tree | 2daddb6ae4d77e8a91a8378dac0774c70ae72e4d /src | |
parent | e9da89ac2fd71a172a235034b5541ce8db917fac (diff) |
first working version of run at telnet client (needs further testing)
Diffstat (limited to 'src')
-rw-r--r-- | src/helsinki.at/rhimportd/ctrlTelnet.go | 29 |
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) + } } } |