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
c5360b50
Commit
c5360b50
authored
Jul 10, 2020
by
Давид Добряков
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vim editing bug fixed
parent
801271f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
Makefile
Makefile
+3
-0
watcher.py
redirector/watcher.py
+16
-3
No files found.
Makefile
0 → 100644
View file @
c5360b50
reinstall
:
pip uninstall nginx-redirector
-y
&&
python setup.py develop
redirector/watcher.py
View file @
c5360b50
...
...
@@ -19,7 +19,7 @@ class RedirectorWatch:
self
.
logger
=
logger
.
Logger
(
"redirector-watch.log"
)
self
.
redirector
=
Redirector
()
self
.
parser
=
parser
.
ConfigReader
(
logger
=
self
.
logger
)
self
.
mask
=
pyinotify
.
IN_MODIFY
self
.
mask
=
pyinotify
.
ALL_EVENTS
self
.
pool
=
{}
...
...
@@ -50,6 +50,7 @@ class RedirectorWatch:
super
()
.
__init__
(
*
args
,
**
kwargs
)
def
process_IN_MODIFY
(
self
,
event
):
print
(
'event is'
,
event
)
try
:
redirector_watch
.
pool
[
yaml_file
][
1
]
.
stop
()
except
RuntimeError
as
e
:
...
...
@@ -58,6 +59,17 @@ class RedirectorWatch:
print
(
"Proccessing..."
)
self
.
redirector
.
generate
(
yaml_file
,
event
.
pathname
)
redirector_watch
.
watch
(
yaml_file
)
# fix bug with vim editing
def
process_default
(
self
,
event
):
if
event
.
maskname
==
'IN_MOVE_SELF'
:
redirector_watch
.
pool
[
yaml_file
]
=
None
# correct path, deleting "-unknown-path" from path
corr_path
=
event
.
pathname
.
replace
(
'-unknown-path'
,
''
)
print
(
"Processing..."
)
self
.
redirector
.
generate
(
yaml_file
,
corr_path
)
redirector_watch
.
watch
(
yaml_file
)
return
Watch
# we suggest that self.watch_manager already exists
...
...
@@ -68,14 +80,15 @@ class RedirectorWatch:
notifier
=
pyinotify
.
ThreadedNotifier
(
wm
,
Watch_class
(
redirector
=
self
.
redirector
))
notifier
.
start
()
self
.
pool
[
yaml_file
]
=
[
wm
,
notifier
]
print
(
'self.pool is'
,
self
.
pool
)
#print('self.pool is', self.pool)
#print('notifier is', notifier)
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
)
wdd
=
wm
.
add_watch
(
abs_map_path
,
self
.
mask
,
rec
=
True
,
auto_add
=
True
)
class
RedirectorWatchException
(
Exception
):
def
__init__
(
self
,
message
,
errors
):
...
...
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