diff --git a/cmd/cycpost/README.rst b/cmd/cycpost/README.rst deleted file mode 100644 index f537353..0000000 --- a/cmd/cycpost/README.rst +++ /dev/null @@ -1,38 +0,0 @@ - -Cyclus Inventory Tool -====================== - -The inventory tool builds an inventory table for fast querying of agent -resource inventory. The table has 5 columns: - -* SimID: a cyclus simulation ID -* ResID: a resource ID -* AgentID: a cyclus agent ID -* StartTime: timestep the resource identified by ResID was first present inside the agent identified by AgentID -* EndTime: timestep the resource identified by ResID was last present inside the agent identified by AgentID - -An agent X's inventory at time t can be determined by Querying for all ResID's -that have ``(AgentID == X) AND (StartTime <= t) AND (EndTime > t)``. This -query can be joined with the Resources, Agents, and Compositions tables -to retrieve the desired inventory information. - -To build the tool: - -#. Install go1.1.2 or later (http://golang.org/doc/install). Be sure - to set the GOROOT env var as per install directions and add ``$GOROOT/bin`` - to your path. - - Alternatively, you can use apt-get or equivalent (if the package is a recent - enough version of Go). You will also need to set the GOPATH env var as the - location to install the sqlite driver dependency. - -#. There is one external dependency. To install it run:: - - go get github.com/mxk/go-sqlite/sqlite3 - -#. Run ``go build`` in the inventory directory (this dir) to build the binary. - - -* The sqlite dependency project actually embeds the entire sqlite C package - inside it. I have sometimes observed problems when the system's default C - compiler is clang rather than gcc when fetching the go-sqlite package. diff --git a/cmd/cycpost/main.go b/cmd/cycpost/main.go deleted file mode 100644 index 16ffc9e..0000000 --- a/cmd/cycpost/main.go +++ /dev/null @@ -1,56 +0,0 @@ -package main - -import ( - "database/sql" - "flag" - "fmt" - "log" - "os" - - _ "github.com/rwcarlsen/cyan/Godeps/_workspace/src/github.com/mxk/go-sqlite/sqlite3" - "github.com/rwcarlsen/cyan/post" -) - -var help = flag.Bool("h", false, "Print this help message.") -var verbose = flag.Bool("v", false, "print verbose progress output") - -func main() { - log.SetFlags(0) - flag.Parse() - - if *help || flag.NArg() != 1 { - fmt.Println("Usage: inventory [cyclus-db]") - fmt.Println("Creates a fast queryable inventory table for a cyclus sqlite output file.\n") - flag.PrintDefaults() - return - } - - fname := flag.Arg(0) - - db, err := sql.Open("sqlite3", fname) - fatalif(err) - defer db.Close() - - fatalif(post.Prepare(db)) - defer post.Finish(db) - - simids, err := post.GetSimIds(db) - fatalif(err) - - for _, simid := range simids { - ctx := post.NewContext(db, simid) - if *verbose { - ctx.Log = log.New(os.Stdout, "", 0) - } - err := ctx.WalkAll() - if err != nil { - fmt.Println(err) - } - } -} - -func fatalif(err error) { - if err != nil { - log.Fatal(err) - } -}