feat: Improve cross-platform directory browsing for Windows and Linux
This commit is contained in:
parent
1662c3d2dd
commit
61b139fcb9
@ -190,23 +190,24 @@ with col1:
|
|||||||
col_src1, col_src2 = st.columns([1, 4])
|
col_src1, col_src2 = st.columns([1, 4])
|
||||||
with col_src1:
|
with col_src1:
|
||||||
if st.button("Browse", key='source_browse'):
|
if st.button("Browse", key='source_browse'):
|
||||||
try:
|
st.info("""
|
||||||
import subprocess
|
To browse for a directory:
|
||||||
result = subprocess.run(
|
1. Open Windows File Explorer
|
||||||
['xdg-open', os.path.expanduser("~")],
|
2. Navigate to your desired folder
|
||||||
capture_output=True,
|
3. Click in the address bar (or press Alt+D)
|
||||||
text=True
|
4. Copy the full path (Ctrl+C)
|
||||||
)
|
5. Paste it here (Ctrl+V)
|
||||||
st.info("Please copy the desired directory path and paste it in the text field above")
|
""")
|
||||||
except Exception as e:
|
|
||||||
st.error(f"Error opening file manager: {str(e)}")
|
|
||||||
|
|
||||||
# Add a check and display for source directory status
|
# Add a check and display for source directory status
|
||||||
if source_dir:
|
if source_dir:
|
||||||
|
# Convert Windows path to Linux path if needed
|
||||||
|
source_dir = source_dir.replace('\\', '/')
|
||||||
if os.path.exists(source_dir):
|
if os.path.exists(source_dir):
|
||||||
st.success(f"✅ Source directory exists: {source_dir}")
|
st.success(f"✅ Source directory exists: {source_dir}")
|
||||||
else:
|
else:
|
||||||
st.error(f"❌ Source directory not found: {source_dir}")
|
st.error(f"❌ Source directory not found: {source_dir}")
|
||||||
|
st.info("Make sure the path is accessible to the Linux server")
|
||||||
|
|
||||||
# Destination Directory
|
# Destination Directory
|
||||||
dest_dir = st.text_input("Destination Directory Path",
|
dest_dir = st.text_input("Destination Directory Path",
|
||||||
@ -217,19 +218,19 @@ with col1:
|
|||||||
col_dest1, col_dest2 = st.columns([1, 4])
|
col_dest1, col_dest2 = st.columns([1, 4])
|
||||||
with col_dest1:
|
with col_dest1:
|
||||||
if st.button("Browse", key='dest_browse'):
|
if st.button("Browse", key='dest_browse'):
|
||||||
try:
|
st.info("""
|
||||||
import subprocess
|
To browse for a directory:
|
||||||
result = subprocess.run(
|
1. Open Windows File Explorer
|
||||||
['xdg-open', os.path.expanduser("~")],
|
2. Navigate to your desired folder
|
||||||
capture_output=True,
|
3. Click in the address bar (or press Alt+D)
|
||||||
text=True
|
4. Copy the full path (Ctrl+C)
|
||||||
)
|
5. Paste it here (Ctrl+V)
|
||||||
st.info("Please copy the desired directory path and paste it in the text field above")
|
""")
|
||||||
except Exception as e:
|
|
||||||
st.error(f"Error opening file manager: {str(e)}")
|
|
||||||
|
|
||||||
# Add a check and display for destination directory status
|
# Add a check and display for destination directory status
|
||||||
if dest_dir:
|
if dest_dir:
|
||||||
|
# Convert Windows path to Linux path if needed
|
||||||
|
dest_dir = dest_dir.replace('\\', '/')
|
||||||
dest_parent = os.path.dirname(dest_dir)
|
dest_parent = os.path.dirname(dest_dir)
|
||||||
if os.path.exists(dest_parent):
|
if os.path.exists(dest_parent):
|
||||||
if os.path.exists(dest_dir):
|
if os.path.exists(dest_dir):
|
||||||
@ -238,6 +239,7 @@ with col1:
|
|||||||
st.info(f"i️ Destination directory will be created: {dest_dir}")
|
st.info(f"i️ Destination directory will be created: {dest_dir}")
|
||||||
else:
|
else:
|
||||||
st.error(f"❌ Parent directory not found: {dest_parent}")
|
st.error(f"❌ Parent directory not found: {dest_parent}")
|
||||||
|
st.info("Make sure the path is accessible to the Linux server")
|
||||||
|
|
||||||
with col2:
|
with col2:
|
||||||
if file_type == "Excel":
|
if file_type == "Excel":
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user