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
93ece2fd
Commit
93ece2fd
authored
Jul 10, 2020
by
Давид Добряков
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete all useless print() functions
parent
c5360b50
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
10 deletions
+6
-10
parser.py
redirector/utils/parser.py
+2
-3
watcher.py
redirector/watcher.py
+1
-5
test.map
tests/test.map
+2
-1
test.yaml
tests/test.yaml
+1
-1
No files found.
redirector/utils/parser.py
View file @
93ece2fd
...
...
@@ -94,9 +94,8 @@ 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"
):
...
...
@@ -104,7 +103,7 @@ class ConfigReader:
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
((
abs_map_path
,
project_prefix
))
return
return_list
...
...
redirector/watcher.py
View file @
93ece2fd
...
...
@@ -50,11 +50,10 @@ 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
:
print
(
"
hello there"
)
print
(
"
There is a non cricital Exception {}"
.
format
(
e
)
)
redirector_watch
.
pool
[
yaml_file
]
=
None
print
(
"Proccessing..."
)
self
.
redirector
.
generate
(
yaml_file
,
event
.
pathname
)
...
...
@@ -74,14 +73,11 @@ 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)
#print('notifier is', notifier)
def
add_files
(
self
,
file_
,
wm
):
file_list
=
self
.
parser
.
parse_yaml
(
file_
)
...
...
tests/test.map
View file @
93ece2fd
# comment
/some-page /another-page
/old-page /new-page
/very-old-page /very-new-page
# regexp
~^assets/(.+) /new-assets/$1
...
...
tests/test.yaml
View file @
93ece2fd
...
...
@@ -3,5 +3,5 @@ projects:
prefix
:
/test
-
map
:
/home/kantegory/pvt/nginx-redirector/tests/test2.map
prefix
:
/test
prefix
:
/test
2
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