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
92e6aa36
Commit
92e6aa36
authored
Apr 05, 2024
by
w-e-w
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
open_folder as util
parent
bef51aed
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
29 deletions
+35
-29
modules/ui_common.py
modules/ui_common.py
+2
-29
modules/util.py
modules/util.py
+33
-0
No files found.
modules/ui_common.py
View file @
92e6aa36
...
...
@@ -3,13 +3,10 @@ import dataclasses
import
json
import
html
import
os
import
platform
import
sys
import
gradio
as
gr
import
subprocess
as
sp
from
modules
import
call_queue
,
shared
,
ui_tempdir
from
modules
import
call_queue
,
shared
,
ui_tempdir
,
util
from
modules.infotext_utils
import
image_from_url_text
import
modules.images
from
modules.ui_components
import
ToolButton
...
...
@@ -176,31 +173,7 @@ def create_output_panel(tabname, outdir, toprow=None):
except
Exception
:
pass
if
not
os
.
path
.
exists
(
f
):
msg
=
f
'Folder "{f}" does not exist. After you create an image, the folder will be created.'
print
(
msg
)
gr
.
Info
(
msg
)
return
elif
not
os
.
path
.
isdir
(
f
):
msg
=
f
"""
WARNING
An open_folder request was made with an argument that is not a folder.
This could be an error or a malicious attempt to run code on your computer.
Requested path was: {f}
"""
print
(
msg
,
file
=
sys
.
stderr
)
gr
.
Warning
(
msg
)
return
path
=
os
.
path
.
normpath
(
f
)
if
platform
.
system
()
==
"Windows"
:
os
.
startfile
(
path
)
elif
platform
.
system
()
==
"Darwin"
:
sp
.
Popen
([
"open"
,
path
])
elif
"microsoft-standard-WSL2"
in
platform
.
uname
()
.
release
:
sp
.
Popen
([
"wsl-open"
,
path
])
else
:
sp
.
Popen
([
"xdg-open"
,
path
])
util
.
open_folder
(
f
)
with
gr
.
Column
(
elem_id
=
f
"{tabname}_results"
):
if
toprow
:
...
...
modules/util.py
View file @
92e6aa36
...
...
@@ -136,3 +136,36 @@ class MassFileLister:
def
reset
(
self
):
"""Clear the cache of all directories."""
self
.
cached_dirs
.
clear
()
def
open_folder
(
path
):
# import at function level to avoid potential issues
import
gradio
as
gr
import
platform
import
sys
import
subprocess
if
not
os
.
path
.
exists
(
path
):
msg
=
f
'Folder "{path}" does not exist. after you save an image, the folder will be created.'
print
(
msg
)
gr
.
Info
(
msg
)
return
elif
not
os
.
path
.
isdir
(
path
):
msg
=
f
"""
WARNING
An open_folder request was made with an path that is not a folder.
This could be an error or a malicious attempt to run code on your computer.
Requested path was: {path}
"""
print
(
msg
,
file
=
sys
.
stderr
)
gr
.
Warning
(
msg
)
return
path
=
os
.
path
.
normpath
(
path
)
if
platform
.
system
()
==
"Windows"
:
os
.
startfile
(
path
)
elif
platform
.
system
()
==
"Darwin"
:
subprocess
.
Popen
([
"open"
,
path
])
elif
"microsoft-standard-WSL2"
in
platform
.
uname
()
.
release
:
subprocess
.
Popen
([
"wsl-open"
,
path
])
else
:
subprocess
.
Popen
([
"xdg-open"
,
path
])
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