pushed changes relating P2PRC changes for python bindings
This commit is contained in:
BIN
.default.nix.swp
Normal file
BIN
.default.nix.swp
Normal file
Binary file not shown.
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/abstractions"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server"
|
||||
)
|
||||
|
||||
// The Client package where data-types
|
||||
@@ -13,41 +14,51 @@ import (
|
||||
// be export
|
||||
|
||||
//export StartContainer
|
||||
func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string) (output string) {
|
||||
func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string) (output *C.char) {
|
||||
container, err := client.StartContainer(IP, NumPorts, GPU, ContainerName, baseImage)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(container)
|
||||
}
|
||||
|
||||
//export GetSpecs
|
||||
func GetSpecs(IP string) (output string) {
|
||||
func GetSpecs(IP string) (output *C.char) {
|
||||
specs, err := client.GetSpecs(IP)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(specs)
|
||||
}
|
||||
|
||||
//export Init
|
||||
func Init(customConfig string) (output string) {
|
||||
func Init(customConfig string) (output *C.char) {
|
||||
init, err := abstractions.Init(customConfig)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(init)
|
||||
|
||||
}
|
||||
|
||||
func ConvertStructToJSONString(Struct interface{}) string {
|
||||
//export Server
|
||||
func Server() (output *C.char) {
|
||||
_, err := server.Server()
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
|
||||
return ConvertStructToJSONString("")
|
||||
}
|
||||
|
||||
func ConvertStructToJSONString(Struct interface{}) *C.char {
|
||||
jsonBytes, err := json.Marshal(Struct)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
|
||||
// Convert the JSON bytes to a string
|
||||
return string(jsonBytes)
|
||||
return C.CString(string(jsonBytes))
|
||||
}
|
||||
|
||||
func main() {}
|
||||
|
||||
Reference in New Issue
Block a user