Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portion of updates go get things building/running with node 19, python3 #118

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ launchfolder: ~/Library/LaunchAgents
~/Library/LaunchAgents:
@if [ ! -d ~/Library/LaunchAgents ]; then mkdir ~/Library/LaunchAgents; fi;

# --- VIDEO ENABLER ---
# --- VIDEO ENABLER ---

ve_alias: bin/video_enabler

Expand All @@ -99,8 +99,6 @@ repos/osx_ios_device_trigger/osx_ios_device_trigger/main.cpp: | repos/osx_ios_de
# --- VIEW LOG ---

view_log: view_log.go
go get github.com/fsnotify/fsnotify
go get github.com/sirupsen/logrus
go build view_log.go

# --- H264_TO_JPEG ---
Expand Down Expand Up @@ -202,7 +200,7 @@ bin/ios_video_pull: repos/ios_video_pull/ios_video_pull
# --- WDA / WebDriverAgent ---

repos/WebDriverAgent/Carthage/Checkouts/RoutingHTTPServer/Info.plist: | repos/WebDriverAgent
cd repos/WebDriverAgent && ./Scripts/bootstrap.sh
# cd repos/WebDriverAgent && ./Scripts/bootstrap.sh

wda: bin/wda/build_info.json

Expand Down Expand Up @@ -334,7 +332,7 @@ repos/libimobiledevice/Makefile: | repos/libimobiledevice
stf: repos/stf-ios-provider/package-lock.json

repos/stf-ios-provider/package-lock.json: repos/stf-ios-provider/package.json
cd repos/stf-ios-provider && PATH="/usr/local/opt/node@12/bin:$(PATH)" npm install
cd repos/stf-ios-provider && PATH="/usr/local/opt/node/bin:$(PATH)" npm install
touch repos/stf-ios-provider/package-lock.json

# --- OFFLINE STF ---
Expand Down
6 changes: 5 additions & 1 deletion config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"root_path": "[desired stf provider install folder]",
"config_path": "[desired stf provider install folder]/config.json",
"set_working_dir": false
},
"bin_paths": {
"node": "/usr/local/opt/node/bin/node"
}
}

Expand Down Expand Up @@ -69,7 +72,8 @@
"openvpn": "/usr/local/opt/openvpn/sbin/openvpn",
"iproxy": "/usr/local/bin/iproxy",
"wdawrapper": "bin/wda_wrapper",
"ffmpeg": "bin/ffmpeg"
"ffmpeg": "bin/ffmpeg",
"node": "/usr/local/opt/node/bin/node"
},
"repos": {
"stf": "https://github.com/nanoscopic/stf-ios-provider.git",
Expand Down
34 changes: 18 additions & 16 deletions coordinator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"io/ioutil"
"os"

log "github.com/sirupsen/logrus"
uj "github.com/nanoscopic/ujsonin/mod"
)
Expand Down Expand Up @@ -90,6 +90,7 @@ type BinPathConfig struct {
IVF string `json:"ivf"`
VideoEnabler string `json:"video_enabler"`
IosDeploy string `json:"ios-deploy"`
Node string `json:"node"`
}

type VPNConfig struct {
Expand Down Expand Up @@ -118,12 +119,12 @@ type DeviceConfig struct {

func get_device_config( config *Config, udid string ) ( *DeviceConfig ) {
dev := DeviceConfig{}

devs := config.ujson.Get("devices")
if devs == nil {
return nil
}

/*devs.ForEach( func( conf *uj.JNode ) {
oneid := conf.Get("udid").String()
if oneid == udid {
Expand All @@ -133,13 +134,13 @@ func get_device_config( config *Config, udid string ) ( *DeviceConfig ) {
} )*/
dev.Width = 735
dev.Height = 1134

return &dev
}

func read_config( configPath string ) *Config {
var config Config

for {
fh, serr := os.Stat( configPath )
if serr != nil {
Expand All @@ -149,15 +150,15 @@ func read_config( configPath string ) *Config {
"config_path": configPath,
} ).Fatal("Could not read specified config path")
}

var configFile string
switch mode := fh.Mode(); {
case mode.IsDir():
configFile = fmt.Sprintf("%s/config.json", configPath)
case mode.IsRegular():
configFile = configPath
}

configFh, err := os.Open( configFile )
if err != nil {
log.WithFields( log.Fields{
Expand All @@ -167,9 +168,9 @@ func read_config( configPath string ) *Config {
} ).Fatal("failed reading config file")
}
defer configFh.Close()

jsonBytes, _ := ioutil.ReadAll( configFh )

defaultJson := `{
"wda_folder": "./bin/wda",
"device_detector": "api",
Expand Down Expand Up @@ -237,7 +238,8 @@ func read_config( configPath string ) *Config {
"h264_to_jpeg": "bin/decode",
"ivf": "bin/ivf_pull",
"video_enabler": "bin/video_enabler",
"ios-deploy": "bin/ios-deploy"
"ios-deploy": "bin/ios-deploy",
"node": "/usr/local/opt/node/bin/node"
},
"repos":{
"stf": "https://github.com/nanoscopic/stf-ios-provider.git",
Expand All @@ -249,7 +251,7 @@ func read_config( configPath string ) *Config {
"devices":[
]
}`

config = Config{
MirrorFeedPort: 8000,
WDAProxyPort: 8100,
Expand All @@ -259,23 +261,23 @@ func read_config( configPath string ) *Config {
DecodeInPort: 7879,
UsbmuxdPort: 9920,
}

err = json.Unmarshal( []byte( defaultJson ), &config )
if err != nil {
log.Fatal( "1 ", err )
}

err = json.Unmarshal( jsonBytes, &config )
if err != nil {
log.Fatal( "2 ", err )
}

config.ujson, _ = uj.Parse( jsonBytes )

//jsonCombined, _ := json.MarshalIndent(config, "", " ")
//fmt.Printf("Combined config:%s\n", string( jsonCombined ) )
//os.Exit(0)

if config.ConfigPath != "" {
configPath = config.ConfigPath
continue
Expand Down
1 change: 1 addition & 0 deletions coordinator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/elastic/go-sysinfo v1.4.0
github.com/fsnotify/fsnotify v1.4.7
github.com/go-cmd/cmd v1.2.0
github.com/google/gops v0.3.27 // indirect
github.com/jviney/go-proc v0.2.0
github.com/nanoscopic/ujsonin v1.9.0
github.com/sirupsen/logrus v1.4.2
Expand Down
11 changes: 5 additions & 6 deletions coordinator/proc_device_unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ func proc_device_ios_unit( o ProcOptions, uuid string, curIP string) {
if o.config.Video.UseVnc && o.config.Video.Enabled {
vncPort = o.devd.vncPort
}

secure := o.config.FrameServer.Secure
var frameServer string
if secure {
frameServer = fmt.Sprintf("wss://%s:%d/echo", curIP, o.devd.vidPort)
} else {
frameServer = fmt.Sprintf("ws://%s:%d/echo", curIP, o.devd.vidPort)
}

curDir, _ := os.Getwd()

o.args = []string{
fmt.Sprintf("--inspect=0.0.0.0:%d", o.devd.devIosPort),
"runmod.js" , "device-ios",
Expand Down Expand Up @@ -71,7 +71,7 @@ func proc_device_ios_unit( o ProcOptions, uuid string, curIP string) {
"clickHeight": o.devd.clickHeight,
"frame_server": frameServer,
}

devd := o.devd
o.stderrHandler = func( line string, plog *log.Entry ) (bool) {
if strings.Contains( line, "Now owned by" ) {
Expand Down Expand Up @@ -115,8 +115,7 @@ func proc_device_ios_unit( o ProcOptions, uuid string, curIP string) {
return true
}
o.procName = "stf_device_ios"
o.binary = "/usr/local/opt/node@12/bin/node"
o.binary = o.config.BinPaths.Node
o.startDir = "./repos/stf-ios-provider"
proc_generic( o )
}

8 changes: 4 additions & 4 deletions coordinator/proc_stf_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ import (

func proc_stf_provider( o ProcOptions, curIP string ) {
o.binary = o.config.BinPaths.IosVideoStream

serverHostname := o.config.Stf.HostName
clientHostname, _ := os.Hostname()
serverIP := o.config.Stf.Ip

location := fmt.Sprintf("macmini/%s", clientHostname)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macmini is pretty weird hardcode, is it needed for something at all?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was put here as when this code was used, the names of the machines were not very descriptive, but they were all mac minis. Really this should be a name prefix that can be set if desired in config.

if o.config.Stf.Location != "" {
location = o.config.Stf.Location
}

o.startFields = log.Fields {
"client_ip": curIP,
"server_ip": serverIP,
"client_hostname": clientHostname,
"server_hostname": serverHostname,
"location": location,
}
o.binary = "/usr/local/opt/node@12/bin/node"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess this could be even shitfed into config.json?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, such things could be shifted into config. I think in this case I did not do so as the proper version and location of node should be detected via additional code instead of being hardcoded.

o.binary = o.config.BinPaths.Node
o.args = []string {
"--inspect=127.0.0.1:9230",
"runmod.js" , "provider",
Expand Down
Loading