Changeset 6314


Ignore:
Timestamp:
Nov 15, 2017, 5:46:26 PM (2 years ago)
Author:
Juanma
Message:

add conf files

Location:
taskscheduler/trunk/fuentes
Files:
7 added
10 edited
1 moved

Legend:

Unmodified
Added
Removed
  • taskscheduler/trunk/fuentes/client-scheduler.install/usr/share/n4d/python-plugins/SchedulerClient.py

    r6269 r6314  
    4646                        else:
    4747                                n4d=xmlrpc.ServerProxy("https://localhost:9779")
    48                         tasks=n4d.get_tasks("","SchedulerServer",prefix)
     48                        tasks=n4d.get_tasks("","SchedulerServer",prefix)['data']
    4949                        #Delete files
    5050                        for f in os.listdir(self.cron_dir):
  • taskscheduler/trunk/fuentes/debian/changelog

    r6273 r6314  
    1 taskscheduler (0.1-lliurex1) xenial; urgency=medium
     1taskscheduler (0.2) xenial; urgency=medium
    22
    3   * Initial release (change folder name)
     3  * Add conf files
    44
    5  -- Juanma Navarro Mañez <juanma1980@gmail.com>  Wed, 15 Nov 2017 08:43:11 +0100
     5 -- Juanma Navarro Mañez <juanma1980@gmail.com>  Wed, 15 Nov 2017 17:45:57 +0100
    66
    77taskscheduler (0.1) xenial; urgency=medium
  • taskscheduler/trunk/fuentes/debian/control

    r6270 r6314  
    1010Package: python3-taskscheduler
    1111Architecture: all
    12 Depends: ${misc:Depends}, ${python3:Depends},n4d-taskscheduler-server,n4d-taskscheduler-client
     12Depends: ${misc:Depends}, ${python3:Depends} 
    1313Description: Python libraries for taskscheduler
    1414
    1515Package: taskscheduler
    1616Architecture: all
    17 Depends: ${misc:Depends}, ${python3:Depends}, python3-taskscheduler, python3-n4dgtklogin
     17Depends: ${misc:Depends}, ${python3:Depends}, python3-taskscheduler
    1818Description: Main taskschedular program
    1919
    2020Package: n4d-taskscheduler-server
    2121Architecture: all
    22 Depends: ${misc:Depends}, ${python3:Depends}
     22Depends: ${misc:Depends}, ${python3:Depends}, python3-taskscheduler
    2323Description: Server side of taskscheduler
    2424
  • taskscheduler/trunk/fuentes/lliurex-po/taskscheduler/es.po

    r6269 r6314  
    88"Project-Id-Version: \n"
    99"Report-Msgid-Bugs-To: \n"
    10 "POT-Creation-Date: 2017-11-14 14:40+0100\n"
    11 "PO-Revision-Date: 2017-11-14 14:44+0100\n"
     10"POT-Creation-Date: 2017-11-15 16:16+0100\n"
     11"PO-Revision-Date: 2017-11-15 16:16+0100\n"
    1212"Last-Translator: \n"
    1313"Language-Team: \n"
     
    3232
    3333#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:58
    34 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:665
    35 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:702
     34#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:664
     35#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:703
    3636msgid "Command"
    3737msgstr "Acción"
     
    6969msgstr "Añadir una tarea"
    7070
    71 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:301
    72 msgid "toolbutton"
    73 msgstr ""
    74 
    75 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:314
     71#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:313
    7672msgid "Reload tasks"
    7773msgstr "Refrescar las tareas"
    7874
    79 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:327
     75#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:326
    8076msgid "Manage custom commands"
    8177msgstr "Gestionar comandos personalizados"
    8278
    83 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:350
     79#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:349
    8480msgid "Show remote tasks"
    8581msgstr "Ver tareas remotas"
    8682
    87 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:354
     83#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:353
    8884msgid "Show tasks scheduled for the clients"
    8985msgstr "Muestra las tareas programadas en los clientes"
    9086
    91 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:364
    92 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:589
     87#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:363
     88#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:583
    9389msgid "Show local tasks"
    9490msgstr "Ver tareas locales"
    9591
    96 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:368
     92#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:367
    9793msgid "Show tasks scheduled for this computer"
    9894msgstr "Muestra las tareas programadas en este ordenador"
    9995
    100 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:393
     96#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:392
    10197msgid "Search a task"
    10298msgstr "Busca una tarea"
    10399
    104 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:457
     100#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:456
    105101msgid ""
    106102"From here you can define new commands to cover your needs.\n"
     
    113109"necesite lanzar (si lanza alguno)."
    114110
    115 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:579
     111#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:573
    116112msgid "Show the remote tasks"
    117113msgstr "Ver las tareas remotas"
    118114
    119 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:580
     115#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:574
    120116msgid "show remote tasks"
    121117msgstr "ver tareas remotas"
    122118
    123 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:588
     119#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:582
    124120msgid "show the local tasks"
    125121msgstr "ver las tareas locales"
     
    253249msgstr "Cada"
    254250
    255 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:527
     251#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:528
    256252msgid "There's another instance of Task Scheduler running."
    257253msgstr "Hay otra instancia del programador de tareas en ejecución"
    258254
    259 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:546
     255#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:547
    260256msgid ""
    261257"Welcome to the Task Scheduler for Lliurex.\n"
     
    271267"*Consultar las tareas programadas</sub>"
    272268
    273 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:547
     269#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:548
    274270msgid "Task Scheduler"
    275271msgstr "Programador de Tareas"
    276272
    277 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:634
     273#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:633
    278274msgid "Task"
    279275msgstr "Tarea"
    280276
    281 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:641
     277#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:640
    282278msgid "Serial"
    283279msgstr "Serial"
    284280
    285 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:649
     281#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:648
    286282msgid "When"
    287283msgstr "Cuando"
    288284
    289 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:657
     285#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:656
    290286msgid "Remove"
    291287msgstr "Eliminar"
    292288
    293 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:693
     289#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:692
    294290msgid "A descriptive name for the command"
    295291msgstr "Un nombre descriptivo para el comando"
    296292
     293#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:693
    297294#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:694
    298 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:695
    299295msgid "Task name"
    300296msgstr "Nombre de la tarea"
     
    324320msgstr "Argumentos"
    325321
    326 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:823
     322#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:825
    327323msgid "Are you sure to delete this task?"
    328324msgstr "¿Desea borrar esta tarea?"
    329325
    330 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:848
     326#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:850
    331327msgid "Task saved"
    332328msgstr "Tarea guardada"
    333329
    334 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:911
     330#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:913
    335331msgid "Task updated"
    336332msgstr "Tarea actualizada"
  • taskscheduler/trunk/fuentes/lliurex-po/taskscheduler/taskscheduler.pot

    r6269 r6314  
    99"Project-Id-Version: PACKAGE VERSION\n"
    1010"Report-Msgid-Bugs-To: \n"
    11 "POT-Creation-Date: 2017-11-14 14:39+0100\n"
     11"POT-Creation-Date: 2017-11-15 16:16+0100\n"
    1212"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    3131
    3232#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:58
    33 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:665
    34 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:702
     33#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:664
     34#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:703
    3535msgid "Command"
    3636msgstr ""
     
    6868msgstr ""
    6969
    70 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:301
    71 msgid "toolbutton"
    72 msgstr ""
    73 
    74 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:314
     70#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:313
    7571msgid "Reload tasks"
    7672msgstr ""
    7773
    78 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:327
     74#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:326
    7975msgid "Manage custom commands"
    8076msgstr ""
    8177
    82 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:350
     78#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:349
    8379msgid "Show remote tasks"
    8480msgstr ""
    8581
    86 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:354
     82#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:353
    8783msgid "Show tasks scheduled for the clients"
    8884msgstr ""
    8985
    90 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:364
    91 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:589
     86#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:363
     87#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:583
    9288msgid "Show local tasks"
    9389msgstr ""
    9490
    95 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:368
     91#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:367
    9692msgid "Show tasks scheduled for this computer"
    9793msgstr ""
    9894
    99 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:393
     95#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:392
    10096msgid "Search a task"
    10197msgstr ""
    10298
    103 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:457
     99#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:456
    104100msgid ""
    105101"From here you can define new commands to cover your needs.\n"
     
    108104msgstr ""
    109105
    110 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:579
     106#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:573
    111107msgid "Show the remote tasks"
    112108msgstr ""
    113109
    114 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:580
     110#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:574
    115111msgid "show remote tasks"
    116112msgstr ""
    117113
    118 #: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:588
     114#: ../scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui:582
    119115msgid "show the local tasks"
    120116msgstr ""
     
    248244msgstr ""
    249245
    250 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:527
     246#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:528
    251247msgid "There's another instance of Task Scheduler running."
    252248msgstr ""
    253249
    254 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:546
     250#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:547
    255251msgid ""
    256252"Welcome to the Task Scheduler for Lliurex.\n"
     
    261257msgstr ""
    262258
    263 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:547
     259#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:548
    264260msgid "Task Scheduler"
    265261msgstr ""
    266262
    267 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:634
     263#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:633
    268264msgid "Task"
    269265msgstr ""
    270266
    271 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:641
     267#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:640
    272268msgid "Serial"
    273269msgstr ""
    274270
    275 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:649
     271#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:648
    276272msgid "When"
    277273msgstr ""
    278274
    279 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:657
     275#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:656
    280276msgid "Remove"
    281277msgstr ""
    282278
     279#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:692
     280msgid "A descriptive name for the command"
     281msgstr ""
     282
    283283#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:693
    284 msgid "A descriptive name for the command"
    285 msgstr ""
    286 
    287284#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:694
    288 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:695
    289285msgid "Task name"
    290286msgstr ""
     
    314310msgstr ""
    315311
    316 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:823
     312#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:825
    317313msgid "Are you sure to delete this task?"
    318314msgstr ""
    319315
    320 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:848
     316#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:850
    321317msgid "Task saved"
    322318msgstr ""
    323319
    324 #: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:911
     320#: ../scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py:913
    325321msgid "Task updated"
    326322msgstr ""
  • taskscheduler/trunk/fuentes/python3-taskscheduler.install/usr/share/taskscheduler/taskscheduler.py

    r6269 r6314  
    1818                self.n4dserver=self._n4d_connect()
    1919                self.n4dclient=self._n4d_connect('localhost')
    20                 self.tasks_dir="/etc/scheduler/conf.d"
     20                self.conf_dir="/etc/scheduler/conf.d/"
     21                self.tasks_dir=self.conf_dir+'/tasks'
    2122                self.custom_tasks=self.tasks_dir+"/custom.json"
    22                 self.commands_file=self.tasks_dir+'/commands.json'
     23                self.commands_file=self.conf_dir+'/commands/commands.json'
    2324                self.sched_dir="/etc/scheduler/tasks.d"
    2425                self.local_tasks_dir=self.sched_dir+"/local"
     
    2829        def _debug(self,msg):
    2930                if (self.dbg):
    30                         print("Scheduler Client: %s" % msg)
     31                        print("Scheduler lib: %s" % msg)
    3132        #def _debug
    3233       
    3334        def set_credentials(self,credentials):
    3435                self.credentials=credentials
     36        #def set_credentials
    3537
    3638        def get_available_tasks(self):
    37 #               tasks=[]
    3839                tasks={}
    39                 wrkfiles=self._get_wrkfiles('available')
    40                 for wrkfile in wrkfiles:
    41                         task=self._read_tasks_file(wrkfile)
    42                         if task:
    43 #                               tasks.append(task)
    44                                 tasks.update(task)
    45                 self._debug(str(tasks))
     40                n4d_server=self.n4dserver
     41                tasks=n4d_server.get_available_tasks("","SchedulerServer")['data'].copy()
     42                n4d_server=self.n4dclient
     43                tasks.update(n4d_server.get_available_tasks("","SchedulerServer")['data'])
    4644                return tasks
     45        #def get_available_tasks
    4746
    4847        def get_scheduled_tasks(self,task_type):
     
    5352                else:
    5453                        n4d_server=self.n4dclient
    55                 tasks=n4d_server.get_tasks("","SchedulerServer",task_type)
    56                 self._debug(str(tasks))
     54                tasks=n4d_server.get_tasks("","SchedulerServer",task_type)['data']
    5755                return tasks
     56        #def get_scheduled_tasks
    5857
    5958        def get_task_description(self,task_cmd):
     
    6261                self._debug("Getting desc for %s"%task_cmd)
    6362                tasks=self.get_available_tasks()
    64                 for task_desc,task_data in tasks.items():
    65                         for action,cmd in task_data.items():
    66                                 if cmd==task_cmd:
    67                                         desc=action
    68                                         sw_found=True
     63                try:
     64                        for task_desc,task_data in tasks.items():
     65                                for action,cmd in task_data.items():
     66                                        if cmd==task_cmd:
     67                                                desc=action
     68                                                sw_found=True
     69                                                break
     70                                if sw_found:
    6971                                        break
    70                         if sw_found:
    71                                 break
     72                except Exception as e:
     73                        print(e)
     74                        self._debug(("Error ocurred when looking for %s")%task_cmd)
    7275                return desc
    7376        #def get_task_description
     
    97100                                wrkfiles.append(wrkdir+'/'+f)
    98101                return wrkfiles
     102        #def _get_wrkfiles
    99103
    100104        def get_commands(self):
     
    105109                        except Exception as e:
    106110                                print(e)
    107                                 self.errormsg=(("unable to open %s") % self.commands_file)
    108                                 self.status=1
    109                                 self._debug(self.errormsg)
     111                                self._debug(("unable to open %s") % self.commands_file)
    110112                return(cmds)
     113        #def get_commands
    111114
    112115        def get_command_cmd(self,cmd_desc):
     
    116119                        cmd=commands[cmd_desc]
    117120                return cmd
     121        #def get_command_cmd
    118122
    119123        def write_custom_task(self,cmd_name,cmd,parms):
    120124                n4d_server=self.n4dserver
    121                 tasks=n4d_server.write_custom_task(self.credentials,"SchedulerServer",cmd_name,cmd,parms)
     125                result=n4d_server.write_custom_task(self.credentials,"SchedulerServer",cmd_name,cmd,parms)
     126                return (result['status'])
     127        #def write_custom_task
    122128
    123129        def _read_tasks_file(self,wrkfile):
     
    129135                        except Exception as e:
    130136                                print(e)
    131                                 self.errormsg=(("unable to open %s") % wrkfile)
    132                                 self.status=1
    133                                 self._debug(self.errormsg)
     137                                self._debug(("unable to open %s") % wrkfile)
    134138                return(tasks)
    135139        #def _read_tasks_file
     
    154158                tasks=n4d_server.remove_task(self.credentials,"SchedulerServer",task_type,task_name,task_serial,task_cmd)
    155159                self._debug(tasks)
     160        #def remove_task
    156161
    157162        def _n4d_connect(self,server='server'):
  • taskscheduler/trunk/fuentes/scheduler-gui.install/usr/share/taskscheduler/bin/taskScheduler.py

    r6269 r6314  
    4646                except:
    4747                        self.flavour="client"
     48                self.ldm_helper='/usr/sbin/sched-ldm.sh'
    4849
    4950        def _debug(self,msg):
    5051                if DBG:
    5152                        print("taskDetails: %s"%msg)
     53        #def _debug
    5254
    5355        def _format_widget_for_grid(self,widget):
     
    6365                        widget.set_width_chars(2)
    6466                        widget.set_max_width_chars(3)
     67        #def _format_widget_for_grid
    6568
    6669        def _load_interval_data(self,widget=None,handler=None):
     
    9396                        self.cmb_interval.handler_unblock(handler)
    9497                        self._parse_scheduled(True)
     98        #def _load_interval_data
    9599       
    96100        def _load_date_data(self):
     
    99103                        self.cmb_dates.append_text(i)
    100104                self.cmb_dates.set_active(0)
     105        #def _load_date_data
    101106       
    102107        def _load_special_date_data(self):
     
    105110                        self.cmb_special_dates.append_text(i)
    106111                self.cmb_special_dates.set_active(0)
     112        #def _load_special_date_data
    107113
    108114        def _load_date_time_data(self,date_type):
     
    135141                                widget.append_text(str(i+inc))
    136142                widget.set_active(0)
     143        #def _load_date_time_data
    137144
    138145        def render_form(self,gtkGrid,btn_apply=True):
     
    264271                #signals
    265272                return (gtkGrid)
     273        #def render_form
    266274
    267275        def load_task_details(self,task_name,task_serial,task_data,task_type):
     
    341349                self.chk_special_dates.set_active(False)
    342350                self.chk_interval.set_active(False)
     351        #def clear_screen
    343352       
    344353        def _set_sensitive_widget(self,widget_dic):
    345354                for widget,status in widget_dic.items():
    346355                        widget.set_sensitive(status)
     356        #def _set_sensitive_widget
    347357       
    348358        def _changed_interval(self):
     
    483493                details=self._parse_screen()
    484494                self.lbl_info.set_text("Task schedule: "+(self.parser.parse_taskData(details)))
     495        #def _parse_scheduled
    485496
    486497        def update_task_details(self,widget=None):
     
    502513                details['cmd']=self.scheduler_client.get_task_command(self.task_cmd)
    503514                if 'lmd' in details.keys():
    504                         details['cmd']='/usr/sbin/sched_helper.sh '+details['cmd']
     515                        details['cmd']=self.ldm_helper+' '+details['cmd']
    505516                task={}
    506517                task[self.task_name]={self.task_serial:details}
    507518                self._debug("Saving %s"%task)
    508519                return task
     520        #def get_task_details
    509521
    510522class TaskScheduler:
     
    515527                except:
    516528                        self.flavour="client"
     529                self.last_task_type='remote'
     530                self.ldm_helper='/usr/sbin/sched-ldm.sh'
    517531                       
    518532        #def __init__           
     
    521535                if DBG:
    522536                        print("taskScheduler: %s"%msg)
     537        #def _debug
    523538
    524539        def is_scheduler_running(self):
     
    528543                        dialog.run()
    529544                        sys.exit(1)
     545        #def is_scheduler_running
    530546
    531547        def start_gui(self):
     
    546562                desc=_("Welcome to the Task Scheduler for Lliurex.\nFrom here you can:\n<sub>* Schedule tasks in the local pc\n* Distribute tasks among all the pcs in the network\n*Show scheduled tasks</sub>")
    547563                self.login.set_info_text("<span foreground='black'>Task Scheduler</span>",_("Task Scheduler"),"<span foreground='black'>"+desc+"</span>")
    548 #               self.login.set_info_background(from_color='#FFFFFF',to_color='#EEDD00',gradient='radial')
    549 #               self.login.set_info_background(image='/usr/share/backgrounds/lliurex/lliurex16-classroom.png',cover=True)
    550564                self.login.set_info_background(image='/usr/share/backgrounds/lliurex/lliurex-blueprint.png',cover=True)
    551565                self.login.after_validation_goto(self._signin)
     
    684698                self.chk_remote=builder.get_object("swt_remote")
    685699                self.chk_local=builder.get_object("swt_local")
     700        #def _load_task_list_gui
    686701
    687702        def _load_manage_tasks(self,builder):
    688703                self.manage_box=builder.get_object("manage_box")
    689                 task_box=builder.get_object("custom_task_box")
    690                 task_box.set_margin_left(12)
    691                 task_box.set_margin_top(12)
     704                custom_grid=builder.get_object("custom_grid")
     705                custom_grid.set_margin_left(12)
     706                custom_grid.set_margin_top(12)
    692707                txt_taskname=Gtk.Entry()
    693708                txt_taskname.set_tooltip_text(_("A descriptive name for the command"))
    694709                txt_taskname.set_placeholder_text(_("Task name"))
    695                 task_box.pack_start(Gtk.Label(_("Task name")),True,True,0)
    696                 task_box.pack_start(txt_taskname,True,True,0)
     710                lbl_name=Gtk.Label(_("Task name"))
     711                lbl_name.set_halign(Gtk.Align.END)
     712                custom_grid.attach(lbl_name,0,0,1,1)
     713                custom_grid.attach(txt_taskname,1,0,1,1)
    697714                cmb_cmds=Gtk.ComboBoxText()
    698715                cmds=self.scheduler_client.get_commands()
     
    700717                        cmb_cmds.append_text(cmd)
    701718
    702                 task_box.pack_start(Gtk.Label(_("Command")),True,True,0)
    703                 task_box.pack_start(cmb_cmds,True,True,0)
    704                 detail_box=builder.get_object("custom_detail_box")
    705                 detail_box.set_margin_left(12)
    706                 detail_box.set_margin_top(12)
     719                lbl_cmd=Gtk.Label(_("Command"))
     720                lbl_cmd.set_halign(Gtk.Align.END)
     721                custom_grid.attach(lbl_cmd,0,1,1,1)
     722                custom_grid.attach(cmb_cmds,1,1,1,1)
    707723                chk_parm_is_file=Gtk.CheckButton(_("Needs a file"))
    708724                chk_parm_is_file.set_tooltip_text(_("Mark if the command will launch a file"))
     
    713729                txt_params.set_placeholder_text(_("Needed arguments"))
    714730                txt_params.set_tooltip_text(_("Put here the arguments for the command (if any)"))
    715                 detail_box.pack_start(Gtk.Label(_("Arguments")),True,True,0)
    716                 detail_box.pack_start(txt_params,True,True,0)
    717                 detail_box.pack_start(chk_parm_is_file,True,True,0)
    718                 detail_box.pack_start(btn_file,True,True,0)
     731                lbl_arg=Gtk.Label(_("Arguments"))
     732                lbl_arg.set_halign(Gtk.Align.END)
     733                custom_grid.attach(lbl_arg,2,1,1,1)
     734                custom_grid.attach(txt_params,3,1,1,1)
     735                custom_grid.attach(chk_parm_is_file,2,0,1,1)
     736                custom_grid.attach(btn_file,3,0,1,1)
    719737                btn_file.set_sensitive(False)
    720738                self.btn_apply_manage=builder.get_object("btn_apply_manage")
     
    722740                self.btn_cancel_manage=builder.get_object("btn_cancel_manage")
    723741                self.btn_cancel_manage.connect("clicked",self._cancel_manage_clicked)
     742        #def _load_manage_tasks
    724743       
    725744        def _enable_filechooser(self,widget,filechooser):
     
    765784                                                parsed_calendar=''
    766785                                                parsed_calendar=parser.parse_taskData(task)
    767                                                 task['cmd']=task['cmd'].replace('/usr/sbin/sched_helper.sh ','')
     786                                                task['cmd']=task['cmd'].replace(self.ldm_helper+' ','')
    768787                                                task['action']=self.scheduler_client.get_task_description(task['cmd'])
    769788                                                self.tasks_store.append(("<span font='Roboto'><b>"+task['action']+"</b></span>\n"+\
     
    862881                        self.btn_local_tasks.set_active(False)
    863882                        self.btn_local_tasks.props.active=False
     883                        self.last_task_type='remote'
    864884                else:
    865885                        self.btn_remote_tasks.set_active(False)
    866886                        self.btn_remote_tasks.props.active=False
     887                        self.last_task_type='local'
    867888                self.populate_tasks_tv(task_type)
    868889                self.tasks_tv.set_model(self.tasks_store_filter)
     
    884905                self.cmb_task_names.remove_all()
    885906                tasks=self.scheduler_client.get_available_tasks()
    886 #               for task in tasks:
    887907                for name in tasks.keys():
    888908                        if name not in names:
     
    899919                task_name=self.cmb_task_names.get_active_text()
    900920                if task_name:
    901 #                       for task in tasks:
    902921                        for action in tasks[task_name].keys():
    903922                                if action not in actions:
     
    918937                self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT)
    919938                self.stack.set_visible_child_name("add")
     939                if self.btn_remote_tasks.get_active():
     940                        self.last_task_type='remote'
     941                else:
     942                        self.last_task_type='local'
    920943                self.load_add_task_details()
    921944        #def add_task_clicked   
     
    924947                self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_RIGHT)
    925948                self.stack.set_visible_child_name("tasks")     
     949                if self.last_task_type=='remote':
     950                        self._block_widget_state(True,self.btn_remote_tasks,self.handler_remote)
     951                else:
     952                        self._block_widget_state(True,self.btn_local_tasks,self.handler_local)
    926953        #def cancel_add_clicked
    927954
     
    954981        def _manage_tasks(self,widget,event):
    955982                self._debug("Loading manage tasks form")
     983                if self.btn_remote_tasks.get_active():
     984                        self.last_task_type='remote'
     985                else:
     986                        self.last_task_type='local'
    956987                self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_RIGHT)
    957988                self.stack.set_visible_child_name("manage")
    958         #def add_task_clicked   
     989                self._block_widget_state(False,self.btn_remote_tasks,self.handler_remote)
     990                self._block_widget_state(False,self.btn_local_tasks,self.handler_local)
     991        #def _manage_tasks     
    959992
    960993        def _cancel_manage_clicked(self,widget):
    961994                self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT)
    962995                self.stack.set_visible_child_name("tasks")     
     996                if self.last_task_type=='remote':
     997                        self._block_widget_state(True,self.btn_remote_tasks,self.handler_remote)
     998                else:
     999                        self._block_widget_state(True,self.btn_local_tasks,self.handler_local)
    9631000
    9641001        ###
  • taskscheduler/trunk/fuentes/scheduler-gui.install/usr/share/taskscheduler/rsrc/taskScheduler.ui

    r6269 r6314  
    299299                    <property name="tooltip_text" translatable="yes">Add a task</property>
    300300                    <property name="halign">baseline</property>
    301                     <property name="label" translatable="yes">toolbutton</property>
    302301                    <property name="use_underline">True</property>
    303302                    <property name="stock_id">gtk-add</property>
     
    476475    </child>
    477476    <child>
    478       <object class="GtkBox" id="custom_task_box">
     477      <object class="GtkGrid" id="custom_grid">
    479478        <property name="visible">True</property>
    480479        <property name="can_focus">False</property>
    481480        <property name="halign">center</property>
     481        <property name="valign">start</property>
    482482        <property name="hexpand">True</property>
    483         <property name="spacing">6</property>
     483        <property name="vexpand">True</property>
     484        <property name="row_spacing">6</property>
     485        <property name="column_spacing">6</property>
     486        <child>
     487          <placeholder/>
     488        </child>
     489        <child>
     490          <placeholder/>
     491        </child>
     492        <child>
     493          <placeholder/>
     494        </child>
     495        <child>
     496          <placeholder/>
     497        </child>
     498        <child>
     499          <placeholder/>
     500        </child>
    484501        <child>
    485502          <placeholder/>
     
    499516        <property name="fill">True</property>
    500517        <property name="position">1</property>
    501       </packing>
    502     </child>
    503     <child>
    504       <object class="GtkBox" id="custom_detail_box">
    505         <property name="visible">True</property>
    506         <property name="can_focus">False</property>
    507         <property name="halign">center</property>
    508         <property name="hexpand">True</property>
    509         <property name="spacing">6</property>
    510         <child>
    511           <placeholder/>
    512         </child>
    513         <child>
    514           <placeholder/>
    515         </child>
    516         <child>
    517           <placeholder/>
    518         </child>
    519       </object>
    520       <packing>
    521         <property name="expand">False</property>
    522         <property name="fill">True</property>
    523         <property name="position">2</property>
    524518      </packing>
    525519    </child>
  • taskscheduler/trunk/fuentes/server-scheduler.install/etc/n4d/conf.d/SchedulerServer

    r6269 r6314  
    88remove_task=adm,admins,teachers
    99get_tasks=*,anonymous
     10get_available_tasks=*,anonymous
  • taskscheduler/trunk/fuentes/server-scheduler.install/usr/share/n4d/python-plugins/SchedulerServer.py

    r6269 r6314  
    1414                self.taskDir="/etc/scheduler/tasks.d"
    1515                self.schedTasksDir=self.taskDir+"/scheduled"
    16                 self.custom_tasks="/etc/scheduler/conf.d/custom.json"
     16                self.available_tasks_dir="/etc/scheduler/conf.d/tasks"
     17                self.custom_tasks=self.available_tasks_dir+"/custom.json"
    1718                self.remote_tasks_dir=self.taskDir+"/remote"
    1819                self.local_tasks_dir=self.taskDir+"/local"
    19                 self.errormsg=''
    20                 sw_readErr=False
    2120        #def __init__
    2221
     
    2726
    2827        def get_tasks(self,task_type):
    29                 scheduled_tasks=[]
     28                result={}
     29                tasks=[]
    3030                wrkfiles=self._get_wrkfiles(task_type)
    3131                for wrkfile in wrkfiles:
    3232                        content=self._read_tasks_file(wrkfile)
    33                         if not self.readErr:
    34                                 scheduled_tasks.append(content)
     33                        tasks.append(content)
    3534                self._debug("Tasks loaded")
    36                 self._debug(str(scheduled_tasks))
    37                 return(scheduled_tasks)
     35                self._debug(str(tasks))
     36                return({'status':True,'data':tasks})
    3837        #def get_tasks
     38
     39        def get_available_tasks(self):
     40                tasks={}
     41                wrkfiles=self._get_wrkfiles('available')
     42                self._debug(wrkfiles)
     43                for wrkfile in wrkfiles:
     44                        task=self._read_tasks_file(wrkfile)
     45                        if task:
     46                                tasks.update(task)
     47                self._debug(str(tasks))
     48                return({'status':True,'data':tasks})
    3949
    4050        def _get_wrkfiles(self,task_type):
    4151                if task_type=='local':
    4252                        wrk_dir=self.local_tasks_dir
    43                 else:
     53                elif task_type=='remote':
    4454                        wrk_dir=self.remote_tasks_dir
     55                elif task_type=='available':
     56                        wrk_dir=self.available_tasks_dir
    4557                if not os.path.isdir(wrk_dir):
    4658                        os.makedirs(wrk_dir)
     
    5062                        wrkfiles.append(wrk_dir+'/'+f)
    5163                return wrkfiles
     64        #def _get_wrkfiles
    5265
    5366        def _read_tasks_file(self,wrkfile):
    5467                self._debug("Opening %s" % wrkfile)
    55                 self.readErr=0
    5668                tasks={}
    5769                if os.path.isfile(wrkfile):
     
    5971                                tasks=json.loads(open(wrkfile).read())
    6072                        except :
    61                                 self.errormsg=(("unable to open %s") % wrkfile)
    62                                 self._debug(self.errormsg)
    63                                 self.readErr=1
     73                                errormsg=(("unable to open %s") % wrkfile)
     74                                self._debug(errormsg)
    6475                return(tasks)
    6576        #def _read_tasks_file
     
    8798                                json.dump(task,json_data,indent=4)
    8899                        self._register_cron_update()
    89                 return ({'status':sw_del,'msg':msg})
     100                return ({'status':sw_del,'data':msg})
     101        #def remove_task
    90102
    91103        def _serialize_task(self,task):
     
    98110                                cont+=1
    99111                return(serial_task)
     112        #def _serialize_task
    100113
    101114        def write_tasks(self,task_type,tasks):
     
    143156                self._register_cron_update()
    144157                self._debug("%s updated" % task_name)
    145                 return({'status':status,'msg':msg})
     158                return({'status':status,'data':msg})
    146159        #def write_tasks
    147160
    148161        def write_custom_task(self,cmd_name,cmd,parms):
     162                status=True
     163                msg=''
    149164                tasks={}
    150165                new_task={}
    151166                if os.path.isfile(self.custom_tasks):
    152167                        tasks=json.loads(open(self.custom_tasks).read())
     168                        if not 'Custom' in tasks.keys():
     169                                tasks['Custom']={}
    153170                else:
    154                         tasks['custom']={}
     171                        tasks['Custom']={}
    155172                new_task[cmd_name]=cmd+' '+parms
    156                 tasks['custom'].update(new_task)
    157                 with open(self.custom_tasks,'w') as json_data:
    158                         json.dump(tasks,json_data,indent=4)
     173                tasks['Custom'].update(new_task)
     174                try:
     175                        with open(self.custom_tasks,'w') as json_data:
     176                                json.dump(tasks,json_data,indent=4)
     177                except Exception as e:
     178                        status=False
     179                        msg=e
     180                return({'status':status,'data':msg})
     181        #def write_custom_task
    159182
    160183        def _register_cron_update(self):
     
    172195                objects["VariablesManager"].set_variable("SCHEDULED_TASKS",val)
    173196                self._debug("New value is %s"%val)
     197        #def _register_cron_update
Note: See TracChangeset for help on using the changeset viewer.