Git Product home page Git Product logo

cr2_usage_bot's Introduction

CR2 Usage Bot

Code base (initial commit) somehow ended up with me through someone else.
Use to make CPR SPA slack channel workspace a bit less serious by posting cat noises;)

Setup Environment

Use the slack-webhook-python package.

Using conda Environment

Set up the environment using conda - you possibly have to install (Mini-) Anaconda.

# pwd is this repo
conda env create --file environment.yml

Install SlackBot, Bot and Webhooks

Go to api.slack.com/apps, then:

  1. Create a SlackApp and optionally set an App icon
  2. Activate the Feature Webhooks

See documentation

Config

Save a list of E-Mails in text file, per default, called mails.txt. It can be empty. All mails are on one line separated by spaces (as you would type it on the command line).

the Slack hook can be saved in a private file in you home directory (for security) and again just save a one-liner. File is per default called ~/.hook:

https://hooks.slack.com/..../.../

Same idea for setting one group (and potentially later more than one). Define group.txt with your information.

Check jobscript.sh for details.

Execution

The python script to send the message can be executed for testing:

python main.py --hook_url URL --message_file path/to/message

Test with example

conda activate slack_app
hook=$(cat hook) # hook should contain weburl
python main.py --hook_url $hook --message_file logs/usage_2022_02_10.txt

Delayed job submission

qsub jobscript.sh -a 02151010 -M [email protected] -A cpr_00000 -W grouplist=cpr_00000 

should start the job on February 15th at 10.10am. So one could also specify the year as defined in the options of -a flag of qsub:

-a date_time
          Available for qsub and qalter only.   

          Defines or redefines the time and date at which  a  job
          is   eligible  for  execution.  Date_time  conforms  to
          [[CC]]YY]MMDDhhmm[.SS], for  the  details,  please  see
          Date_time in:  sge_types(1).

          If this option is used with qsub or if a  corresponding
          value is specified in qmon then a parameter named a and
          the value in the format CCYYMMDDhhmm.SS will be  passed
          to  the defined JSV instances (see -jsv option below or
          find more information concerning JSV in jsv(1))

Crontab

Not supported by Computerome2. Users are not allowed to schedule cron jobs

The job script can be scheduled for regular submission to the cluster using the jobscript.

Adapt jobscript.sh header for defaults and set PRIVATE_HOOK_FILE path to url file (with restricted access)

Add a cron job to crontab -u henweb -e your crontab. The PATH has to be adapted or you have to provide the fullpath to the jobscript.

# every Monday 10 after 10am
10 10 * * 1 qsub jobscript.sh -M [email protected] -A cpr_00000 -W grouplist=cpr_00000

cr2_usage_bot's People

Contributors

enryh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.