Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
common_helper_files
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
common_helper_files
Commits
fb3ab79c
Commit
fb3ab79c
authored
Jul 24, 2017
by
Peter Weidenbach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create symlink creates directories if necessary
parent
f8792d09
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
0 deletions
+5
-0
fail_safe_file_operations.py
common_helper_files/fail_safe_file_operations.py
+1
-0
test_fail_safe_file_operations.py
tests/test_fail_safe_file_operations.py
+4
-0
No files found.
common_helper_files/fail_safe_file_operations.py
View file @
fb3ab79c
...
@@ -116,6 +116,7 @@ def create_symlink(src_path, dst_path):
...
@@ -116,6 +116,7 @@ def create_symlink(src_path, dst_path):
:return: None
:return: None
"""
"""
try
:
try
:
create_dir_for_file
(
dst_path
)
os
.
symlink
(
src_path
,
dst_path
)
os
.
symlink
(
src_path
,
dst_path
)
except
FileExistsError
as
e
:
except
FileExistsError
as
e
:
logging
.
debug
(
"Could not create Link: File exists: {}"
.
format
(
e
))
logging
.
debug
(
"Could not create Link: File exists: {}"
.
format
(
e
))
...
...
tests/test_fail_safe_file_operations.py
View file @
fb3ab79c
...
@@ -77,6 +77,10 @@ class Test_FailSafeFileOperations(unittest.TestCase):
...
@@ -77,6 +77,10 @@ class Test_FailSafeFileOperations(unittest.TestCase):
symlink_path
=
os
.
path
.
join
(
self
.
tmp_dir
.
name
,
'test_symlink'
)
symlink_path
=
os
.
path
.
join
(
self
.
tmp_dir
.
name
,
'test_symlink'
)
create_symlink
(
test_file_path
,
symlink_path
)
create_symlink
(
test_file_path
,
symlink_path
)
self
.
assertEqual
(
os
.
readlink
(
symlink_path
),
test_file_path
)
self
.
assertEqual
(
os
.
readlink
(
symlink_path
),
test_file_path
)
symlink_path_none_existing_dir
=
os
.
path
.
join
(
self
.
tmp_dir
.
name
,
'some_dir/test_symlink'
)
create_symlink
(
test_file_path
,
symlink_path_none_existing_dir
)
self
.
assertEqual
(
os
.
readlink
(
symlink_path_none_existing_dir
),
test_file_path
)
# check error handling
create_symlink
(
test_file_path
,
symlink_path
)
create_symlink
(
test_file_path
,
symlink_path
)
def
test_get_safe_name
(
self
):
def
test_get_safe_name
(
self
):
...
...
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