Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
a70ef306
authored
Jan 30, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store: add top list maintainer daemon
parent
b9c84b4d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
miscellaneous/store-server/TopList.py
+49
-0
No files found.
miscellaneous/store-server/TopList.py
0 → 100644
View file @
a70ef306
import
os
,
os
.
path
from
pyinotify
import
WatchManager
,
Notifier
,
ThreadedNotifier
,
EventsCodes
,
ProcessEvent
,
IN_DONT_FOLLOW
,
IN_CREATE
,
IN_MODIFY
import
pwd
COUNT
=
5
wm
=
WatchManager
()
mask
=
IN_CREATE
|
IN_MODIFY
|
IN_DONT_FOLLOW
def
update_new
(
name
):
home
=
pwd
.
getpwuid
(
os
.
stat
(
name
)
.
st_uid
)
.
pw_dir
top_dir
=
os
.
path
.
join
(
home
,
"../.top"
)
try
:
os
.
mkdir
(
top_dir
)
except
OSError
:
pass
try
:
os
.
unlink
(
os
.
path
.
join
(
top_dir
,
str
(
COUNT
)))
except
OSError
:
pass
for
i
in
range
(
1
,
COUNT
):
try
:
os
.
rename
(
os
.
path
.
join
(
top_dir
,
str
(
i
+
1
)),
os
.
path
.
join
(
top_dir
,
str
(
i
)))
except
OSError
:
pass
os
.
symlink
(
name
,
os
.
path
.
join
(
top_dir
,
str
(
COUNT
)))
class
Process
(
ProcessEvent
):
def
process_default
(
self
,
event
):
if
event
.
name
:
update_new
(
os
.
path
.
join
(
event
.
path
,
event
.
name
))
def
main
():
notifier
=
Notifier
(
wm
,
Process
())
wdd
=
wm
.
add_watch
(
'/home'
,
mask
,
rec
=
True
)
while
True
:
# loop forever
try
:
# process the queue of events as explained above
notifier
.
process_events
()
if
notifier
.
check_events
():
# read notified events and enqeue them
notifier
.
read_events
()
except
KeyboardInterrupt
:
# destroy the inotify's instance on this interrupt (stop monitoring)
notifier
.
stop
()
break
if
__name__
==
"__main__"
:
main
()
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