Changeset 6831
- Timestamp:
- Feb 16, 2018, 12:54:54 PM (3 years ago)
- Location:
- taskscheduler/trunk/fuentes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
taskscheduler/trunk/fuentes/python3-taskscheduler.install/usr/share/taskscheduler/taskscheduler.py
r6824 r6831 56 56 if type(result)==type({}): 57 57 tasks=result.copy() 58 result=self.n4dclient.get_tasks("","SchedulerServer")['data'] 58 # result=self.n4dclient.get_tasks("","SchedulerServer")['data'] 59 result=self.n4dclient.get_local_tasks("","SchedulerServer") 59 60 if type(result)==type({}): 60 61 if tasks: … … 68 69 else: 69 70 tasks.update(result.copy()) 70 print(tasks)71 71 return tasks 72 72 #def get_scheduled_tasks … … 115 115 return wrkfiles 116 116 #def _get_wrkfiles 117 118 def add_command(self,cmd_name,cmd): 119 if self.n4dserver: 120 self.n4dserver.add_command(self.credentials,"SchedulerServer",cmd_name,cmd) 121 else: 122 self.n4dclient.add_command(self.credentials,"SchedulerServer",cmd_name,cmd) 117 123 118 124 def get_commands(self): -
taskscheduler/trunk/fuentes/scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py
r6824 r6831 250 250 self.manage_box=builder.get_object("manage_box") 251 251 custom_grid=builder.get_object("custom_grid") 252 custom_grid.set_margin_left( 12)253 custom_grid.set_margin_top( 12)252 custom_grid.set_margin_left(WIDGET_MARGIN*2) 253 custom_grid.set_margin_top(WIDGET_MARGIN*2) 254 254 txt_taskname=Gtk.Entry() 255 255 txt_taskname.set_tooltip_text(_("A descriptive name for the command")) … … 257 257 lbl_name=Gtk.Label(_("Task name")) 258 258 lbl_name.set_halign(Gtk.Align.END) 259 btn_add_cmd=Gtk.Button.new_from_stock(Gtk.STOCK_ADD) 259 260 custom_grid.attach(lbl_name,0,0,1,1) 260 261 custom_grid.attach(txt_taskname,1,0,1,1) 261 262 cmb_cmds=Gtk.ComboBoxText() 262 cmds=self.scheduler.get_commands() 263 i18n_cmd={} 264 for cmd in cmds.keys(): 265 i18n_cmd[_(cmd)]=cmd 266 cmb_cmds.append_text(_(cmd)) 267 263 i18n_cmd=self.load_cmb_cmds(cmb_cmds) 268 264 lbl_cmd=Gtk.Label(_("Command")) 269 265 lbl_cmd.set_halign(Gtk.Align.END) 270 266 custom_grid.attach(lbl_cmd,0,1,1,1) 271 267 custom_grid.attach(cmb_cmds,1,1,1,1) 268 custom_grid.attach(btn_add_cmd,2,1,1,1) 272 269 chk_parm_is_file=Gtk.CheckButton(_("Needs a file")) 273 270 chk_parm_is_file.set_tooltip_text(_("Mark if the command will launch a file")) … … 280 277 lbl_arg=Gtk.Label(_("Arguments")) 281 278 lbl_arg.set_halign(Gtk.Align.END) 282 custom_grid.attach(lbl_arg, 2,1,1,1)283 custom_grid.attach(txt_params, 3,1,1,1)284 custom_grid.attach(chk_parm_is_file, 2,0,1,1)285 custom_grid.attach(btn_file, 3,0,1,1)279 custom_grid.attach(lbl_arg,3,1,1,1) 280 custom_grid.attach(txt_params,4,1,1,1) 281 custom_grid.attach(chk_parm_is_file,3,0,1,1) 282 custom_grid.attach(btn_file,4,0,1,1) 286 283 btn_file.set_sensitive(False) 287 284 self.btn_apply_manage=builder.get_object("btn_apply_manage") … … 291 288 self.btn_cancel_manage=builder.get_object("btn_cancel_manage") 292 289 self.btn_cancel_manage.connect("clicked",self._cancel_manage_clicked) 290 btn_add_cmd.connect("clicked",self._add_cmd_clicked,cmb_cmds) 293 291 #def _load_manage_tasks 292 293 def load_cmb_cmds(self,cmb_cmds): 294 cmb_cmds.remove_all() 295 cmds=self.scheduler.get_commands() 296 i18n_cmd={} 297 for cmd in cmds.keys(): 298 i18n_cmd[_(cmd)]=cmd 299 cmb_cmds.append_text(_(cmd)) 300 return(i18n_cmd) 301 302 def _add_cmd_clicked(self,*args): 303 cmb_cmds=args[-1] 304 def show_file_dialog(*args): 305 file_response=dlg_file.run() 306 if file_response == Gtk.ResponseType.OK: 307 txt_file.set_text(dlg_file.get_filename()) 308 # dlg_file.destroy() 309 dialog=Gtk.Dialog() 310 dialog.add_buttons(Gtk.STOCK_APPLY,42,"Close",Gtk.ResponseType.CLOSE) 311 box=dialog.get_content_area() 312 hbox=Gtk.Grid() 313 hbox.set_column_spacing(WIDGET_MARGIN) 314 hbox.set_row_spacing(WIDGET_MARGIN) 315 lbl_name=Gtk.Label(_("Action name")) 316 txt_name=Gtk.Entry() 317 txt_name.set_tooltip_text("Enter the name for the action") 318 lbl_file=Gtk.Label(_("Command")) 319 txt_file=Gtk.Entry() 320 txt_file.set_tooltip_text("Enter the command or choose one from the file selector") 321 dlg_file=Gtk.FileChooserDialog(_("Choose a command"),dialog,Gtk.FileChooserAction.OPEN,(Gtk.STOCK_CANCEL,Gtk.ResponseType.CANCEL,Gtk.STOCK_OPEN,Gtk.ResponseType.OK)) 322 btn_file=Gtk.Button.new_from_stock(Gtk.STOCK_FILE) 323 btn_file.connect("clicked",show_file_dialog) 324 hbox.attach(lbl_name,0,0,1,1) 325 hbox.attach(txt_name,1,0,1,1) 326 hbox.attach(lbl_file,0,1,1,1) 327 hbox.attach(txt_file,1,1,1,1) 328 hbox.attach(btn_file,2,1,1,1) 329 hbox.attach(Gtk.Separator(),0,2,2,1) 330 box.add(hbox) 331 box.show_all() 332 response=dialog.run() 333 if response==Gtk.ResponseType.CLOSE: 334 dialog.destroy() 335 if response==42: 336 self._add_custom_cmd(txt_name.get_text(),txt_file.get_text()) 337 self.load_cmb_cmds(cmb_cmds) 338 #def _add_cmd_clicked 339 340 def _add_custom_cmd(self,name,cmd): 341 self.scheduler.add_command(name,cmd) 294 342 295 343 def _enable_filechooser(self,widget,filechooser): … … 300 348 #def _enable_filechooser 301 349 302 def _add_custom_task(self,widget,w_name,w_cmd,w_parms,w_chk,w_file,i18n_cmd ):350 def _add_custom_task(self,widget,w_name,w_cmd,w_parms,w_chk,w_file,i18n_cmd=None): 303 351 name=w_name.get_text() 304 352 cmd=w_cmd.get_active_text() 305 cmd_desc=i18n_cmd[cmd] 353 if i18n_cmd: 354 cmd_desc=i18n_cmd[cmd] 355 else: 356 cmd_desc=cmd 306 357 parms=w_parms.get_text() 307 358 cmd=self.scheduler.get_command_cmd(cmd_desc) -
taskscheduler/trunk/fuentes/server-scheduler.install/etc/n4d/conf.d/SchedulerServer
r6818 r6831 9 9 get_tasks=*,anonymous 10 10 get_remote_tasks=*,anonymous 11 get_local_tasks=*,anonymous 11 12 get_available_tasks=*,anonymous 13 add_command=adm,admins,teachers -
taskscheduler/trunk/fuentes/server-scheduler.install/usr/share/n4d/python-plugins/SchedulerServer.py
r6824 r6831 11 11 class SchedulerServer(): 12 12 def __init__(self): 13 self.dbg= 013 self.dbg=1 14 14 self.tasks_dir="/etc/scheduler/tasks.d" 15 15 self.schedTasksDir=self.tasks_dir+"/scheduled" … … 18 18 self.remote_tasks_dir=self.tasks_dir+"/remote" 19 19 self.local_tasks_dir=self.tasks_dir+"/local" 20 self.commands_file='/etc/scheduler/conf.d/commands/commands.json' 20 21 #def __init__ 21 22 … … 32 33 local_tasks={} 33 34 tasks_data=self._read_wrkfiles(self.tasks_dir)['data'].copy() 34 for task_serial in tasks_data.keys(): 35 36 for task_name,serial_data in tasks_data.items(): 35 37 sw_continue=False 36 for task in task_serial.keys(): 37 if ['spread'] in task.keys(): 38 if task['spread']==True: 39 sw_continue=True 40 break 41 if sw_continue: 42 continue 43 local_tasks.update(task_serial) 38 for serial,data in serial_data.items(): 39 if 'spread' in data.keys(): 40 if data['spread']==False: 41 if task_name in local_tasks.keys(): 42 # remote_tasks[task_name].update({'r'+serial:tasks_data[task_name][serial]}) 43 local_tasks[task_name]['r'+serial]=tasks_data[task_name][serial] 44 else: 45 local_tasks[task_name]={'r'+serial:tasks_data[task_name][serial]} 46 else: 47 if task_name in local_tasks.keys(): 48 local_tasks[task_name]['r'+serial]=tasks_data[task_name][serial] 49 else: 50 local_tasks[task_name]={'r'+serial:tasks_data[task_name][serial]} 44 51 return local_tasks 45 52 … … 244 251 #def write_custom_task 245 252 253 def add_command(self,cmd_name,cmd): 254 self._debug("Adding command %s - %s"%(cmd_name,cmd)) 255 commands={} 256 dict_cmd={cmd_name:cmd} 257 if os.path.isfile(self.commands_file): 258 commands=json.loads(open(self.commands_file,"rb").read()) 259 commands.update(dict_cmd) 260 with open(self.commands_file,'w') as json_data: 261 json.dump(commands,json_data,indent=4) 262 #def add_command 263 246 264 def _register_cron_update(self): 247 265 self._debug("Registering trigger var")
Note: See TracChangeset
for help on using the changeset viewer.