Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
45b4f6da
Commit
45b4f6da
authored
5 years ago
by
Andrei Plamada
Browse files
Options
Downloads
Patches
Plain Diff
first draft symlinks
parent
db01a243
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
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
pybis/src/python/pybis/dataset.py
+3
-0
3 additions, 0 deletions
pybis/src/python/pybis/dataset.py
pybis/src/python/pybis/utils.py
+44
-0
44 additions, 0 deletions
pybis/src/python/pybis/utils.py
with
48 additions
and
0 deletions
.gitignore
+
1
−
0
View file @
45b4f6da
...
@@ -8,6 +8,7 @@ datastore_server/source/core-plugins
...
@@ -8,6 +8,7 @@ datastore_server/source/core-plugins
openbis/source/core-plugins
openbis/source/core-plugins
*/bin/*
*/bin/*
**/.DS_Store
**/.DS_Store
*__pycache__/
*$py.class
*$py.class
**/.pydevproject
**/.pydevproject
**/.shredder
**/.shredder
...
...
This diff is collapsed.
Click to expand it.
pybis/src/python/pybis/dataset.py
+
3
−
0
View file @
45b4f6da
...
@@ -162,6 +162,9 @@ class DataSet(
...
@@ -162,6 +162,9 @@ class DataSet(
return
self
.
data
[
'
physicalData
'
][
'
status
'
]
return
self
.
data
[
'
physicalData
'
][
'
status
'
]
except
Exception
:
except
Exception
:
return
None
return
None
@property
def
sftp_path
(
self
):
return
os
.
path
(
self
.
experiment
.
identifier
[
1
:],
self
.
permId
)
def
archive
(
self
,
remove_from_data_store
=
True
):
def
archive
(
self
,
remove_from_data_store
=
True
):
fetchopts
=
{
fetchopts
=
{
...
...
This diff is collapsed.
Click to expand it.
pybis/src/python/pybis/utils.py
+
44
−
0
View file @
45b4f6da
...
@@ -255,3 +255,47 @@ def extract_userId(user):
...
@@ -255,3 +255,47 @@ def extract_userId(user):
return
str
(
user
)
return
str
(
user
)
def
check_symlink
(
target_dir
:
str
)
->
Path
:
# there are several options: basically resolvable symlink, non-resolvable symlink, does not exist at all or exists but it is not a symlink
target_dir_path
=
Path
(
target_dir
)
if
target_dir_path
.
is_symlink
()
and
target_dir_path
.
exists
():
return
target_dir_path
.
resolve
()
elif
target_dir_path
.
is_symlink
()
and
not
target_dir_path
.
exists
():
raise
FileNotFoundError
(
f
"
target_dir=
{
target_dir
}
is non-resolvable symlink. No such file or directory:
{
target_dir_path
.
resolve
()
}
"
)
elif
not
target_dir_path
.
is_symlink
()
and
not
target_dir_path
.
exists
():
raise
FileNotFoundError
(
f
"
target_dir=
{
target_dir
}
does not exist
"
)
else
:
raise
ValueError
(
f
"
target_dir=
{
target_dir
}
exists but it is not a symlink
"
)
def
create_symlink
(
target_dir
:
str
,
source_dir
:
str
,
mountpoint
:
str
,
replace_if_symlink
:
bool
=
True
):
# Path(mountpoint,ds.experiment.identifier[1:],ds.permId)
# replace_if_symlink will replace the the target_dir in case it is an existing symlink
mountpoint_path
=
Path
(
mountpoint
)
# check mountpoint
if
not
mountpoint_path
.
is_mount
():
if
not
mountpoint_path
.
exists
():
raise
FileNotFoundError
(
f
"
mountpoint=
{
mountpoint
}
does not exist
"
)
else
:
raise
ValueError
(
f
"
mountpoint=
{
mountpoint
}
exists but it is not a mount
"
)
# join mountpoint and source_dir
# if source_dir is absolute we have to remove "/" to be able to join it with mountpoint
# I did not find any way to achieve this in case they are pathlib.Path
if
source_dir
[
0
]
==
"
/
"
:
source_dir
=
source_dir
[
1
:]
source_dir_path
=
Path
(
mountpoint
,
source_dir
)
target_dir_path
=
Path
(
target_dir
)
if
target_dir_path
.
is_symlink
()
and
replace_if_symlink
:
target_dir_path
.
unlink
()
target_dir_path
.
symlink_to
(
source_dir_path
,
target_is_directory
=
True
)
\ No newline at end of file
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