Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nginx-redirector
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
nginx-redirector
Commits
801271f2
You need to sign in or sign up before continuing.
Commit
801271f2
authored
Jul 09, 2020
by
Давид Добряков
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct abs_map_path getting for watcher.py
parent
1385575c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
+22
-3
.gitignore
.gitignore
+2
-0
parser.py
redirector/utils/parser.py
+8
-1
watcher.py
redirector/watcher.py
+12
-2
No files found.
.gitignore
View file @
801271f2
...
...
@@ -5,3 +5,5 @@ venv/
dist/
nginx_redirector.egg-info/
build/
*.log
redirector/utils/parser.py
View file @
801271f2
...
...
@@ -94,12 +94,19 @@ class ConfigReader:
@staticmethod
def
parse_yaml
(
file_dir
):
return_list
=
[]
#print('file_dir is', file_dir)
yaml_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
file_dir
))
print
(
'yaml_dir from parse_yaml'
,
yaml_dir
)
with
open
(
file_dir
,
'r'
)
as
stream
:
data
=
load
(
stream
,
Loader
=
Loader
)
for
project
in
data
.
get
(
"projects"
):
map_path
=
project
.
get
(
"map"
)
rel_map_path
=
os
.
path
.
relpath
(
map_path
,
start
=
yaml_dir
)
abs_map_path
=
os
.
path
.
join
(
rel_map_path
,
yaml_dir
,
os
.
path
.
basename
(
map_path
))
abs_map_path
=
os
.
path
.
normpath
(
abs_map_path
)
print
(
'abs_map_path from parse_yaml'
,
abs_map_path
)
project_prefix
=
project
.
get
(
"prefix"
)
return_list
.
append
((
map_path
,
project_prefix
))
return_list
.
append
((
abs_
map_path
,
project_prefix
))
return
return_list
def
parse_map
(
self
,
map_file
,
yaml_file
):
...
...
redirector/watcher.py
View file @
801271f2
...
...
@@ -27,9 +27,15 @@ class RedirectorWatch:
if
not
yaml_file
:
raise
self
.
RedirectorWatchException
(
"yaml_file list is empty"
,
Exception
)
Watch
=
self
.
create_watch_class
(
yaml_file
)
yaml_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
yaml_file
))
for
map_path
,
_
in
self
.
parser
.
parse_yaml
(
yaml_file
):
print
(
'is error here'
,
map_path
)
self
.
redirector
.
generate
(
yaml_file
,
map_path
)
rel_map_path
=
os
.
path
.
relpath
(
map_path
,
start
=
yaml_dir
)
abs_map_path
=
os
.
path
.
join
(
rel_map_path
,
yaml_dir
,
os
.
path
.
basename
(
map_path
))
abs_map_path
=
os
.
path
.
normpath
(
abs_map_path
)
self
.
redirector
.
generate
(
yaml_file
,
abs_map_path
)
try
:
self
.
set_inotify
(
yaml_file
,
Watch
)
except
pyinotify
.
PyinotifyError
as
e
:
...
...
@@ -56,14 +62,17 @@ class RedirectorWatch:
# we suggest that self.watch_manager already exists
def
set_inotify
(
self
,
yaml_file
,
Watch_class
):
print
(
'trying to set_inotify on {}'
.
format
(
yaml_file
))
wm
=
pyinotify
.
WatchManager
()
self
.
add_files
(
yaml_file
,
wm
)
notifier
=
pyinotify
.
ThreadedNotifier
(
wm
,
Watch_class
(
redirector
=
self
.
redirector
))
notifier
.
start
()
self
.
pool
[
yaml_file
]
=
[
wm
,
notifier
]
print
(
'self.pool is'
,
self
.
pool
)
def
add_files
(
self
,
file_
,
wm
):
file_list
=
self
.
parser
.
parse_yaml
(
file_
)
for
map_path
,
_
in
file_list
:
abs_map_path
=
os
.
path
.
abspath
(
map_path
)
wdd
=
wm
.
add_watch
(
abs_map_path
,
self
.
mask
,
rec
=
True
)
...
...
@@ -88,3 +97,4 @@ def watch(args=None):
if
__name__
==
"__main__"
:
watch
()
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