Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
leversc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
leversc
Commits
3eac8fbe
Commit
3eac8fbe
authored
3 years ago
by
ac (mbp)
Browse files
Options
Downloads
Patches
Plain Diff
leversc for mac
parent
a0edea89
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/MATLAB/@leversc/show.m
+116
-109
116 additions, 109 deletions
src/MATLAB/@leversc/show.m
src/Python/leversc pip requirements.txt
+3
-0
3 additions, 0 deletions
src/Python/leversc pip requirements.txt
src/Python/leversc.py
+3
-1
3 additions, 1 deletion
src/Python/leversc.py
with
122 additions
and
110 deletions
src/MATLAB/@leversc/show.m
+
116
−
109
View file @
3eac8fbe
function
show
(
obj
,
im
)
function
show
(
obj
,
im
)
host
=
'http://localhost'
;
host
=
'http://localhost'
;
base_port
=
3000
;
base_port
=
3000
;
imD
=
obj
.
imageData
;
imD
=
obj
.
imageData
;
if
isfield
(
imD
,
'imageData'
)
if
isfield
(
imD
,
'imageData'
)
imD
=
imD
.
imageData
;
imD
=
imD
.
imageData
;
end
end
fignum
=
obj
.
figNumber
;
fignum
=
obj
.
figNumber
;
if
(
fignum
<=
0
)
if
(
fignum
<=
0
)
warning
(
'Figure number must be positive!'
);
warning
(
'Figure number must be positive!'
);
return
;
end
if
isstr
(
im
)
flist
=
dir
(
im
);
if
isempty
(
flist
)
fprintf
(
2
,
'leversc.show :: could not find LEVER file %s\n'
,
im
);
return
;
return
;
end
end
im
=
fullfile
(
flist
(
1
)
.
folder
,
flist
(
1
)
.
name
);
im
=
strrep
(
im
,
'*'
,
'/'
);
end
port
=
base_port
+
fignum
;
chksrv
=
obj
.
check_server
(
host
);
if
(
isempty
(
chksrv
)
)
leverpath
=
''
;
if
(
~
isempty
(
which
(
'ljsPath'
))
)
leverpath
=
ljsPath
();
end
if
isstr
(
im
)
if
isstr
(
im
)
flist
=
dir
(
im
);
launch_electron
(
port
,
fignum
,
fullfile
(
pwd
(),
'.lever'
),
leverpath
,
im
);
if
isempty
(
flist
)
return
fprintf
(
2
,
'leversc.show :: could not find LEVER file %s\n'
,
im
);
else
return
;
launch_electron
(
port
,
fignum
,
fullfile
(
pwd
(),
'.lever'
),
leverpath
,[]);
end
im
=
fullfile
(
flist
(
1
)
.
folder
,
flist
(
1
)
.
name
);
im
=
strrep
(
im
,
'*'
,
'/'
);
end
end
% Poll for app for 5 seconds
port
=
base_port
+
fignum
;
for
i
=
1
:
10
chksrv
=
obj
.
check_server
(
host
);
if
(
~
isempty
(
obj
.
check_server
(
host
))
)
if
(
isempty
(
chksrv
)
)
break
;
leverpath
=
''
;
if
(
~
isempty
(
which
(
'ljsPath'
))
)
leverpath
=
ljsPath
();
end
if
isstr
(
im
)
launch_electron
(
port
,
fignum
,
fullfile
(
pwd
(),
'.lever'
),
leverpath
,
im
);
return
else
launch_electron
(
port
,
fignum
,
fullfile
(
pwd
(),
'.lever'
),
leverpath
,[]);
end
% Poll for app for 5 seconds
for
i
=
1
:
10
if
(
~
isempty
(
obj
.
check_server
(
host
))
)
break
;
end
pause
(
0.5
);
end
end
elseif
isstr
(
im
)
pause
(
0.5
);
% electron app is running - need new instance
strDB
=
im
;
strDB
=
strrep
(
strDB
,
'/'
,
'*'
);
strDB
=
strrep
(
strDB
,
'\'
,
'*'
);
url
=
[
obj
.
host
':'
num2str
(
obj
.
port
)
'/strDB/'
strDB
];
webwrite
(
url
,
''
);
return
end
end
elseif
isstr
(
im
)
% electron app is running - need new instance
strDB
=
im
;
strDB
=
strrep
(
strDB
,
'/'
,
'*'
);
strDB
=
strrep
(
strDB
,
'\'
,
'*'
);
url
=
[
obj
.
host
':'
num2str
(
obj
.
port
)
'/strDB/'
strDB
];
webwrite
(
url
,
''
);
return
end
chksrv
=
obj
.
check_server
(
host
);
chksrv
=
obj
.
check_server
(
host
);
if
(
isempty
(
chksrv
)
)
if
(
isempty
(
chksrv
)
)
warning
([
'Can
''
t find server: '
host
':'
num2str
(
port
)]);
warning
([
'Can
''
t find server: '
host
':'
num2str
(
port
)]);
return
;
return
;
end
end
sendProvider
=
http
.
io
.
LBinProvider
(
im
,
imD
);
sendProvider
=
http
.
io
.
LBinProvider
(
im
,
imD
);
req
=
matlab
.
net
.
http
.
RequestMessage
(
'post'
,
[],
sendProvider
);
req
=
matlab
.
net
.
http
.
RequestMessage
(
'post'
,
[],
sendProvider
);
url
=
[
host
':'
num2str
(
port
)
'/loadfig/'
num2str
(
fignum
)];
url
=
[
host
':'
num2str
(
port
)
'/loadfig/'
num2str
(
fignum
)];
resp
=
req
.
send
(
url
);
resp
=
req
.
send
(
url
);
end
end
function
launch_electron
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
)
function
launch_electron
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
)
if
(
ispc
()
)
if
(
ispc
()
)
launch_electron_windows
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
);
launch_electron_windows
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
);
elseif
(
is
unix
()
)
elseif
(
is
mac
()
)
launch_electron_
posix
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
);
launch_electron_
mac
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
);
elseif
(
is
mac
()
)
elseif
(
is
unix
()
)
launch_electron_
mac
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
);
launch_electron_
posix
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
);
else
else
error
(
'Unsupported operating system!'
);
error
(
'Unsupported operating system!'
);
end
end
end
end
function
launch_electron_mac
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
)
function
launch_electron_mac
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
)
elec_cmd
=
'open -a leverjs '
;
if
(
~
isempty
(
leverpath
)
)
if
(
~
isempty
(
leverpath
)
)
elec_path
=
fullfile
(
leverpath
,
'node_modules'
,
'.bin'
,
'electron'
);
% mac matlab does not have /usr/local/bin on path
elec_cmd
=
[
elec_path
' '
fullfile
(
leverpath
,
'elever'
,
'main.js'
)];
% that is typically where nodejs goes
else
% add it to path
[
status
,
~
]
=
system
([
'which '
elec_cmd
]);
% if this fails, check and fix that node is on the path that matlab
if
(
status
~=
0
)
% finds in path1
error
([
'Cannot find '
elec_cmd
' please add to system path!'
]);
path1
=
getenv
(
'PATH'
);
end
path1
=
[
path1
':/usr/local/bin'
];
end
setenv
(
'PATH'
,
path1
);
if
exist
(
'strDB'
,
'var'
)
&&
~
isempty
(
strDB
)
elec_path
=
fullfile
(
leverpath
,
'node_modules'
,
'.bin'
,
'electron'
);
elec_cmd
=
[
elec_cmd
' --leverFile='
strDB
' '
];
elec_cmd
=
[
elec_path
' '
fullfile
(
leverpath
,
'elever'
,
'main.js'
)];
end
else
cmd
=
[
elec_cmd
' --port='
num2str
(
port
)
' --title="figure '
num2str
(
fignum
)
'"'
' &'
];
% run from installed app leverjs
system
(
cmd
);
elec_cmd
=
[
'open -a leverjs -n --args --root='
pwd
()
' '
];
end
if
exist
(
'strDB'
,
'var'
)
&&
~
isempty
(
strDB
)
elec_cmd
=
[
elec_cmd
' --leverFile='
strDB
' '
];
end
cmd
=
[
elec_cmd
' --port='
num2str
(
port
)
' --title="figure '
num2str
(
fignum
)
'"'
' &'
];
system
(
cmd
);
end
end
function
launch_electron_posix
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
)
function
launch_electron_posix
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
)
elec_cmd
=
'leverjs'
;
elec_cmd
=
'leverjs'
;
if
(
~
isempty
(
leverpath
)
)
if
(
~
isempty
(
leverpath
)
)
elec_path
=
fullfile
(
leverpath
,
'node_modules'
,
'.bin'
,
'electron'
);
elec_path
=
fullfile
(
leverpath
,
'node_modules'
,
'.bin'
,
'electron'
);
elec_cmd
=
[
elec_path
' '
fullfile
(
leverpath
,
'elever'
,
'main.js'
)];
elec_cmd
=
[
elec_path
' '
fullfile
(
leverpath
,
'elever'
,
'main.js'
)];
else
else
[
status
,
~
]
=
system
([
'which '
elec_cmd
]);
[
status
,
~
]
=
system
([
'which '
elec_cmd
]);
if
(
status
~=
0
)
if
(
status
~=
0
)
error
([
'Cannot find '
elec_cmd
' please add to system path!'
]);
error
([
'Cannot find '
elec_cmd
' please add to system path!'
]);
end
end
end
if
exist
(
'strDB'
,
'var'
)
&&
~
isempty
(
strDB
)
end
elec_cmd
=
[
elec_cmd
' --leverFile='
strDB
' '
];
if
exist
(
'strDB'
,
'var'
)
&&
~
isempty
(
strDB
)
end
elec_cmd
=
[
elec_cmd
' --leverFile='
strDB
' '
];
cmd
=
[
elec_cmd
' --port='
num2str
(
port
)
' --title="figure '
num2str
(
fignum
)
'"'
' &'
];
end
system
(
cmd
);
cmd
=
[
elec_cmd
' --port='
num2str
(
port
)
' --title="figure '
num2str
(
fignum
)
'"'
' &'
];
system
(
cmd
);
end
end
function
launch_electron_windows
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
)
function
launch_electron_windows
(
port
,
fignum
,
workdir
,
leverpath
,
strDB
)
elec_cmd
=
'leverjs.exe'
;
elec_cmd
=
'leverjs.exe'
;
if
(
~
isempty
(
leverpath
)
)
if
(
~
isempty
(
leverpath
)
)
elec_path
=
fullfile
(
leverpath
,
'node_modules'
,
'electron'
,
'dist'
,
'electron.exe'
);
elec_path
=
fullfile
(
leverpath
,
'node_modules'
,
'electron'
,
'dist'
,
'electron.exe'
);
elec_cmd
=
[
elec_path
' '
fullfile
(
leverpath
,
'elever'
,
'main.js'
)];
elec_cmd
=
[
elec_path
' '
fullfile
(
leverpath
,
'elever'
,
'main.js'
)];
else
else
[
status
,
~
]
=
system
([
'where '
elec_cmd
]);
[
status
,
~
]
=
system
([
'where '
elec_cmd
]);
if
(
status
~=
0
)
if
(
status
~=
0
)
error
([
'Cannot find '
elec_cmd
' please add to system path!'
]);
error
([
'Cannot find '
elec_cmd
' please add to system path!'
]);
end
end
if
exist
(
'strDB'
,
'var'
)
&&
~
isempty
(
strDB
)
elec_cmd
=
[
elec_cmd
' --leverFile='
strDB
' '
];
end
end
cmd
=
[
elec_cmd
' --port='
num2str
(
port
)
' --title="figure '
num2str
(
fignum
)
'"'
' &'
];
end
status
=
system
(
cmd
);
if
exist
(
'strDB'
,
'var'
)
&&
~
isempty
(
strDB
)
elec_cmd
=
[
elec_cmd
' --leverFile='
strDB
' '
];
end
cmd
=
[
elec_cmd
' --port='
num2str
(
port
)
' --title="figure '
num2str
(
fignum
)
'"'
' &'
];
status
=
system
(
cmd
);
end
end
This diff is collapsed.
Click to expand it.
src/Python/leversc pip requirements.txt
0 → 100644
+
3
−
0
View file @
3eac8fbe
pip requirements
matplotlib h5py imageio requests
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Python/leversc.py
+
3
−
1
View file @
3eac8fbe
...
@@ -313,7 +313,7 @@ class leversc:
...
@@ -313,7 +313,7 @@ class leversc:
runargs
=
None
runargs
=
None
if
(
leverpath
is
None
):
if
(
leverpath
is
None
):
# Try to run installed leversc from path
# Try to run installed leversc from path
runargs
=
[
"
open
"
,
"
-
n
"
,
"
leverjs.app
"
,
"
--args
"
]
if
leversc
.
_is_macos
()
else
[
"
leverjs
"
]
runargs
=
[
"
open
"
,
"
-
a
"
,
"
leverjs.app
"
,
"
-
n
"
,
"
-
-args
"
]
if
leversc
.
_is_macos
()
else
[
"
leverjs
"
]
else
:
else
:
runargs
=
leversc
.
_get_os_ljselectron_exec
(
leverpath
)
runargs
=
leversc
.
_get_os_ljselectron_exec
(
leverpath
)
...
@@ -324,6 +324,8 @@ class leversc:
...
@@ -324,6 +324,8 @@ class leversc:
if
strDB
is
not
None
:
if
strDB
is
not
None
:
strDB
=
os
.
path
.
abspath
(
strDB
)
strDB
=
os
.
path
.
abspath
(
strDB
)
runargs
.
append
(
"
--leverFile=%s
"
%
strDB
)
runargs
.
append
(
"
--leverFile=%s
"
%
strDB
)
if
leversc
.
_is_macos
:
runargs
.
append
(
"
--root=
"
+
os
.
getcwd
())
port
=
self
.
_base_port
+
self
.
_figNumber
port
=
self
.
_base_port
+
self
.
_figNumber
runargs
.
append
(
"
--port=%s
"
%
port
)
runargs
.
append
(
"
--port=%s
"
%
port
)
runargs
.
append
(
"
--title=figure %s
"
%
self
.
_figNumber
)
runargs
.
append
(
"
--title=figure %s
"
%
self
.
_figNumber
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment