Permalink
Browse files

[tasks] context info and notifications

  • Loading branch information...
1 parent 958da77 commit 2dc3b87a294e9e64e4c70afe708bb3d50c8a2280 @Eugeny Eugeny committed Sep 28, 2013
View
@@ -13,4 +13,5 @@ prune ajenti/plugins/elements
prune ajenti/plugins/ltfs
prune ajenti/plugins/vh
prune ajenti/plugins/test
-prune ajenti/plugins/test*
+prune ajenti/plugins/test*
+prune ajenti/plugins/custom
@@ -81,8 +81,11 @@ def _escape(self, i):
def _total_size(self, items):
return sum(_.size for _ in items)
+ def _has_dirs(self, items):
+ return any(_.isdir for _ in items)
+
def remove(self, items):
- if self._total_size(items) > self.FG_OPERATION_LIMIT:
+ if self._total_size(items) > self.FG_OPERATION_LIMIT or _has_dirs(items):
command = 'rm -vfr -- '
for item in items:
command += self._escape(item)
@@ -95,7 +98,7 @@ def remove(self, items):
os.unlink(i.fullpath)
def move(self, items, dest):
- if self._total_size(items) > self.FG_OPERATION_LIMIT:
+ if self._total_size(items) > self.FG_OPERATION_LIMIT or _has_dirs(items):
command = 'mv -v -- '
for item in items:
command += self._escape(item)
@@ -106,7 +109,7 @@ def move(self, items, dest):
shutil.move(i.fullpath, dest)
def copy(self, items, dest):
- if self._total_size(items) > self.FG_OPERATION_LIMIT:
+ if self._total_size(items) > self.FG_OPERATION_LIMIT or _has_dirs(items):
command = 'cp -rv -- '
for item in items:
command += self._escape(item)
@@ -77,3 +77,6 @@ def query_create_user(self, user):
def query_drop_user(self, user):
self.query("DROP USER `%s`@`%s`" % (user.name, user.host))
+ def query_grant(self, user, db):
+ self.query("GRANT ALL PRIVILEGES ON `%s`.* TO `%s`@`%s`" % (db.name, user.name, user.host))
+ self.query("FLUSH PRIVILEGES")
@@ -43,3 +43,6 @@ def query_create_user(self, user):
def query_drop_user(self, user):
return self.db.query_drop_user(user)
+
+ def query_grant(self, user, db):
+ return self.db.query_grant(user, db)
@@ -70,7 +70,7 @@ def refresh(self):
@on('run-task', 'click')
def on_run_task(self):
- self.manager.run(task_id=self.find('run-task-selector').value)
+ self.manager.run(task_id=self.find('run-task-selector').value, context=self.context)
self.refresh()
@on('create-task', 'click')
@@ -58,6 +58,8 @@ def save(self):
CronManager.get().save_tab('root', tab)
def task_done(self, task):
+ if task.context:
+ task.context.notify('info', _('Task %s finished') % task.name)
if task in self.running_tasks:
self.running_tasks.remove(task)
if not self.running_tasks:
@@ -70,7 +72,7 @@ def refresh(self):
for task in complete_tasks:
self.running_tasks.remove(task)
- def run(self, task=None, task_definition=None, task_id=None):
+ def run(self, task=None, task_definition=None, task_id=None, context=None):
if task_id is not None:
for td in self.task_definitions:
if td.id == task_id:
@@ -81,13 +83,20 @@ def run(self, task=None, task_definition=None, task_id=None):
task.definition = task_definition
task.parallel = task_definition.parallel
+ if context:
+ task.context = context
+
if not task.parallel and self.running_tasks:
self.pending_tasks.append(task)
task.pending = True
+ if task.context:
+ task.context.notify('info', _('Task %s queued') % task.name)
else:
self.running_tasks.append(task)
task.pending = False
task.callback = self.task_done
+ if task.context:
+ task.context.notify('info', _('Task %s started') % task.name)
task.start()
View
@@ -11,7 +11,8 @@
"ajenti.plugins.mysql.main.MySQLPlugin": "{\"password\": \"123\", \"user\": \"root\"}",
"ajenti.plugins.mysql.api.MySQLDB": "{\"password\": \"123\", \"user\": \"root\", \"hostname\": \"localhost\"}",
"ajenti.plugins.notepad.notepad.Notepad": "{\"bookmarks\": [\"/etc/logrotate.conf\"]}",
- "ajenti.plugins.tasks.manager.TaskManager": "{\"job_definitions\": [{\"schedule_hour\": \"*\", \"name\": \"unnamed\", \"task_id\": \"29fd381f-2bf9-4eb5-9cec-deabf423ba03\", \"schedule_special\": \"@yearly\", \"schedule_minute\": \"0\", \"schedule_day_of_month\": \"*\", \"id\": \"d8d3848a-78a3-4eb6-b4ac-bb51988ea1a8\", \"schedule_month\": \"*\", \"schedule_day_of_week\": \"*\"}], \"task_definitions\": [{\"task_class\": \"ajenti.plugins.tasks.tasks.CopyFilesTask\", \"params\": {\"source\": \"/home/eugeny/from\", \"destination\": \"/home/eugeny/to\"}, \"name\": \"unnamed\", \"id\": \"29fd381f-2bf9-4eb5-9cec-deabf423ba03\"}]}",
+ "ajenti.plugins.tasks.manager.TaskManager": "{\"job_definitions\": [{\"schedule_hour\": \"*\", \"name\": \"unnamed\", \"task_id\": \"b815338e-be6e-409d-bb71-c53074128e5e\", \"schedule_special\": \"@yearly\", \"schedule_minute\": \"0\", \"schedule_day_of_month\": \"*\", \"id\": \"d8d3848a-78a3-4eb6-b4ac-bb51988ea1a8\", \"schedule_month\": \"*\", \"schedule_day_of_week\": \"*\"}], \"task_definitions\": [{\"task_class\": \"ajenti.plugins.tasks.tasks.CopyFilesTask\", \"params\": {\"source\": \"/home/eugeny/source\", \"destination\": \"/home/eugeny/dest\"}, \"name\": \"Copy files\", \"id\": \"b815338e-be6e-409d-bb71-c53074128e5e\"}, {\"task_class\": \"ajenti.plugins.elements.tasks.MakeProxyTask\", \"params\": {\"source\": \"/home/eugeny/source\"}, \"name\": \"Update proxy files\", \"id\": \"326dab5d-0c65-4fc9-908a-2b7ee5ea0b34\"}]}",
+ "ajenti.plugins.ltfs.archive.main.LTFSArchivePlugin": "{\"hide-files-from-offline-tapes\": false}",
"ajenti.plugins.elements.projects.main.ElementsProjectManager": "{\"projects\": \"(lp1\\nccopy_reg\\n_reconstructor\\np2\\n(cajenti.plugins.elements.projects.main\\nElementsProject\\np3\\nc__builtin__\\nobject\\np4\\nNtRp5\\n(dp6\\nS'quota_size_soft'\\np7\\nI0\\nsS'description'\\np8\\nS''\\nsS'name'\\np9\\nVtest\\np10\\nsS'quota_size_hard'\\np11\\nI0\\nsS'lock'\\np12\\nNsS'long_description'\\np13\\nS''\\nsS'emulate_avid'\\np14\\nI00\\nsS'affinity'\\np15\\nNsS'directory'\\np16\\nS'test'\\np17\\nsS'path'\\np18\\nV/home/eugeny/Documents\\np19\\nsS'share_afp'\\np20\\nI00\\nsS'share_smb'\\np21\\nI00\\nsS'share_nfs'\\np22\\nI00\\nsS'permissions'\\np23\\n(lp24\\ng2\\n(cajenti.plugins.elements.projects.main\\nElementsProjectPermission\\np25\\ng4\\nNtRp26\\n(dp27\\nS'project'\\np28\\nNsS'user'\\np29\\nS'root'\\np30\\nsbasba.\"}"
},
"password": "sha512|$6$rounds=40000$nIVrqqz638rB8wOo$VbMv8y2lStgcsYxEuu7JfHiEd06eeiSoIbg7Hvivj9K1vPayaCbAiAqtpyOoIkNfIXFmMD0jK6Dd4WFnvywkY1",
View
@@ -12,6 +12,7 @@
'ajenti.plugins.ltfs',
'ajenti.plugins.vh',
'ajenti.plugins.vh*',
+ 'ajenti.plugins.custom*',
'ajenti.plugins.test*',
]

0 comments on commit 2dc3b87

Please sign in to comment.