Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
875bc270
Commit
875bc270
authored
May 11, 2023
by
Aarni Koskela
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
launch.py: Simplify run()
parent
49db24ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
19 deletions
+23
-19
launch.py
launch.py
+23
-19
No files found.
launch.py
View file @
875bc270
...
@@ -88,32 +88,36 @@ def git_tag():
...
@@ -88,32 +88,36 @@ def git_tag():
return
stored_git_tag
return
stored_git_tag
def
run
(
command
,
desc
=
None
,
errdesc
=
None
,
custom_env
=
None
,
live
:
bool
=
default_command_live
):
def
run
(
command
,
desc
=
None
,
errdesc
=
None
,
custom_env
=
None
,
live
:
bool
=
default_command_live
)
->
str
:
if
desc
is
not
None
:
if
desc
is
not
None
:
print
(
desc
)
print
(
desc
)
if
live
:
run_kwargs
=
{
result
=
subprocess
.
run
(
command
,
shell
=
True
,
env
=
os
.
environ
if
custom_env
is
None
else
custom_env
)
"args"
:
command
,
if
result
.
returncode
!=
0
:
"shell"
:
True
,
raise
RuntimeError
(
f
"""{errdesc or 'Error running command'}.
"env"
:
os
.
environ
if
custom_env
is
None
else
custom_env
,
Command: {command}
"encoding"
:
'utf8'
,
Error code: {result.returncode}"""
)
"errors"
:
'ignore'
,
}
return
""
if
not
live
:
run_kwargs
[
"stdout"
]
=
run_kwargs
[
"stderr"
]
=
subprocess
.
PIPE
result
=
subprocess
.
run
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
,
env
=
os
.
environ
if
custom_env
is
None
else
custom_env
)
result
=
subprocess
.
run
(
**
run_kwargs
)
if
result
.
returncode
!=
0
:
if
result
.
returncode
!=
0
:
error_bits
=
[
message
=
f
"""{errdesc or 'Error running command'}.
f
"{errdesc or 'Error running command'}."
,
Command: {command}
f
"Command: {command}"
,
Error code: {result.returncode}
f
"Error code: {result.returncode}"
,
stdout: {result.stdout.decode(encoding="utf8", errors="ignore") if len(result.stdout)>0 else '<empty>'}
]
stderr: {result.stderr.decode(encoding="utf8", errors="ignore") if len(result.stderr)>0 else '<empty>'}
if
result
.
stdout
:
"""
error_bits
.
append
(
f
"stdout: {result.stdout}"
)
raise
RuntimeError
(
message
)
if
result
.
stderr
:
error_bits
.
append
(
f
"stderr: {result.stderr}"
)
return
result
.
stdout
.
decode
(
encoding
=
"utf8"
,
errors
=
"ignore"
)
raise
RuntimeError
(
"
\n
"
.
join
(
error_bits
))
return
(
result
.
stdout
or
""
)
def
check_run
(
command
):
def
check_run
(
command
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment