Skip to content

Commit

Permalink
add basic dataset tabel
Browse files Browse the repository at this point in the history
  • Loading branch information
sfermi committed Jan 31, 2019
1 parent 28850df commit c680815
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 18,229 deletions.
4 changes: 1 addition & 3 deletions cli/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions cli/Gopkg.toml
Expand Up @@ -108,3 +108,7 @@
[prune]
go-tests = true
unused-packages = true

[[constraint]]
name = "github.com/HouzuoGuo/tiedot"
version = "3.4.0"
4 changes: 4 additions & 0 deletions cli/config.go
Expand Up @@ -145,6 +145,10 @@ func validateConfig() {
// create webui folder
webuiFolder := filepath.Join(cvpmPath, "webui")
createFolderIfNotExist(webuiFolder)
// create database folder
databaseFolder := filepath.Join(cvpmPath, "database")
createFolderIfNotExist(databaseFolder)
createFileIfNotExist(filepath.Join(databaseFolder, "cvpm-database.db"))
// check if system log file exists
cvpmLogPath := filepath.Join(cvpmPath, "logs", "system.log")
createFileIfNotExist(cvpmLogPath)
Expand Down
18 changes: 18 additions & 0 deletions cli/contrib.go
@@ -0,0 +1,18 @@
// Copyright 2019 The CVPM Authors. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.

/* This file handles third party contributions and libraries.*/
package main

import (
"net/http"

dataset "github.com/cvpm-contrib/dataset"
"github.com/gin-gonic/gin"
)

// GET /datasets
func GetAllDatasets(c *gin.Context) {
c.JSON(http.StatusOK, dataset.FetchAllDatasets())
}
2 changes: 2 additions & 0 deletions cli/daemon.go
Expand Up @@ -237,6 +237,8 @@ func runServer(port string) {
// Socket Related Routes
r.GET("/socket.io/", socketHandler)
r.POST("/socket.io/", socketHandler)
// Contrib Related Routes
r.GET("/datasets", GetAllDatasets)
r.Handle("WS", "/socket.io/", socketHandler)
r.Handle("WSS", "/socket.io/", socketHandler)
r.Run("0.0.0.0:" + port)
Expand Down
3 changes: 0 additions & 3 deletions cli/shell.go
Expand Up @@ -19,20 +19,17 @@ func pip(args []string) {
proc := NewProcess(localPip, args...)
out := proc.StreamOutput()
logFile := filepath.Join(getLogsLocation(), "system.log")
log.Println(logFile)
file, err := os.OpenFile(logFile, os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
log.Fatalf("failed opening file: %s", err)
}
go func() {
for out.Scan() {
log.Println(out.Text())
_, err := file.WriteString(out.Text() + "\n")
if err != nil {
log.Fatalf("failed writing to file: %s", err)
}
defer file.Close()
log.Println(out.Text())
}
}()
proc.Start()
Expand Down

0 comments on commit c680815

Please sign in to comment.