Пример #1
0
            'job_class_string':
            '%s.%s' % (cls.__module__, cls.__name__),
            'notes':
            'This will print a string in your shell. Check it out!',
            'arguments': [
                # argument1
                {
                    'type': 'string',
                    'description': 'First argument'
                },

                # argument2
                {
                    'type': 'string',
                    'description': 'Second argument'
                }
            ],
            'example_arguments':
            '["first argument AAA", "second argument BBB"]'
        }

    def run(self, argument1, argument2, *args, **kwargs):
        print('Hello from AwesomeJob! Argument1: %s, Argument2: %s' %
              (argument1, argument2))


if __name__ == "__main__":
    # You can easily test this job here
    job = AwesomeJob.create_test_instance()
    job.run(123, 456)
Пример #2
0
            'for APNS cert file path.',
            'arguments': [
                # APNS device token
                {
                    'token': 'string',
                    'description': 'Device token'
                },
                # APNS Title's Alert Text
                {
                    'alert': 'string',
                    'description': 'What do you want to send?'
                },
            ],
            'example_arguments': ('["da1232badh2", "Hello from scheduler"]')
        }

    def run(self, token, alert="Hello World", *args, **kwargs):
        print('Sending %s to %s' % (alert, token))

        cert_file = os.environ[
            'APNS_CERT_PATH'] or 'simple_scheduler/jobs/apns-cert.pem'
        apns = APNs(use_sandbox=False, cert_file=cert_file)
        # Send a notification
        payload = Payload(alert=alert, sound="default", badge=0)
        apns.gateway_server.send_notification(token, payload)


if __name__ == "__main__":
    job = APNSJob.create_test_instance()
    job.run('da1232badh2', 'Hello World')
Пример #3
0
                'You have to set Environment variable SIMPLE_SCHEDULER_SLACK_URL first.'
            )
        else:
            session = requests.Session()
            adapter = requests.adapters.HTTPAdapter(
                max_retries=self.MAX_RETRIES)
            session.mount('http://', adapter)
            session.mount('https://', adapter)

            message += ' // `sent from %s`' % socket.gethostname()
            payload = {
                'channel': channel,
                'username': name,
                'text': message,
                'link_names': 1,
                "mrkdwn": 1,
                'icon_emoji': icon_emoji
            }
            session.request('POST',
                            url,
                            timeout=self.TIMEOUT,
                            headers={'content-type': 'application/json'},
                            data=json.dumps(payload))


if __name__ == "__main__":
    # You can easily test this job here
    job = SlackJob.create_test_instance()
    job.run('#slack-bot-test', 'mdmscheduler', ':satisfied:',
            'Standup, team! @channel')
Пример #4
0
from mdmscheduler import job


class ShellJob(job.JobBase):
    @classmethod
    def meta_info(cls):
        return {
            'job_class_string':
            '%s.%s' % (cls.__module__, cls.__name__),
            'notes':
            ('This will run an executable program. You can specify as many '
             'arguments as you want. This job will pass these arguments to the '
             'program in order.'),
            'arguments': [{
                'type': 'string',
                'description': 'Executable path'
            }],
            'example_arguments':
            '["/usr/local/my_program", "--file", "/tmp/abc", "--mode", "safe"]'
        }

    def run(self, *args, **kwargs):
        call(args)


if __name__ == "__main__":
    # You can easily test this job here
    job = ShellJob.create_test_instance()
    job.run('ls', '-l')
Пример #5
0
                },
                # Request Type
                {
                    'type':
                    'string',
                    'description':
                    'What request type do you want? '
                    '(currently supported: GET/DELETE)'
                },
            ],
            'example_arguments':
            ('["http://localhost:8888/api/v1/jobs", "GET"]'
             '["http://localhost:8888/api/v1/jobs/ba12e", "DELETE"]')
        }

    def run(self, url, request_type, *args, **kwargs):
        print('Calling GET on url: %s' % (url))

        session = requests.Session()
        result = session.request(request_type,
                                 url,
                                 timeout=self.TIMEOUT,
                                 headers=None,
                                 data=None)
        print(result.text)


if __name__ == "__main__":
    job = CurlJob.create_test_instance()
    job.run('http://localhost:888/api/v1/jobs')