cicada 0.6.0__py3-none-any.whl → 0.8.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cicada/cli.py CHANGED
@@ -3,6 +3,7 @@
3
3
  import argparse
4
4
  import sys
5
5
  import inspect
6
+ from pkg_resources import get_distribution
6
7
 
7
8
  from cicada.lib import utils
8
9
 
@@ -15,6 +16,8 @@ from cicada.commands import exec_schedule
15
16
  from cicada.commands import spread_schedules
16
17
  from cicada.commands import archive_schedule_log
17
18
  from cicada.commands import ping_slack
19
+ from cicada.commands import list_schedules
20
+ from cicada.commands import delete_schedule
18
21
 
19
22
 
20
23
  @utils.named_exception_handler("Cicada")
@@ -32,6 +35,9 @@ class Cicada:
32
35
  "spread_schedules",
33
36
  "archive_schedule_log",
34
37
  "ping_slack",
38
+ "list_schedule_ids",
39
+ "delete_schedule",
40
+ "version",
35
41
  ]
36
42
 
37
43
  parser = argparse.ArgumentParser(
@@ -239,6 +245,39 @@ class Cicada:
239
245
  args = parser.parse_args(sys.argv[2:])
240
246
  ping_slack.main(args.text)
241
247
 
248
+ @staticmethod
249
+ def list_schedule_ids():
250
+ """List schedule ids of all schedules"""
251
+ parser = argparse.ArgumentParser(
252
+ allow_abbrev=False,
253
+ add_help=True,
254
+ prog=inspect.stack()[0][3],
255
+ description="List schedule ids of all schedules",
256
+ )
257
+ if len(sys.argv) >= 3:
258
+ parser.print_help(sys.stdout)
259
+ sys.exit(0)
260
+ list_schedules.main()
261
+
262
+ @staticmethod
263
+ def delete_schedule():
264
+ """Delete a schedule using schedule_id"""
265
+ parser = argparse.ArgumentParser(
266
+ allow_abbrev=False,
267
+ add_help=True,
268
+ prog=inspect.stack()[0][3],
269
+ description="Delete a schedule using schedule_id",
270
+ )
271
+ parser.add_argument("--schedule_id", type=str, required=True, help="Id of the schedule")
272
+ # now that we're inside a subcommand, ignore the first TWO args
273
+ args = parser.parse_args(sys.argv[2:])
274
+ delete_schedule.main(args.schedule_id)
275
+
276
+ @staticmethod
277
+ def version():
278
+ """Return version of cicada package"""
279
+ print(get_distribution("cicada").version)
280
+
242
281
 
243
282
  def main():
244
283
  """Cicada agent CLI."""
@@ -0,0 +1,22 @@
1
+ """Delete a schedule using schedule_id."""
2
+
3
+ import sys
4
+
5
+ from tabulate import tabulate
6
+
7
+ from cicada.lib import postgres
8
+ from cicada.lib import scheduler
9
+ from cicada.lib import utils
10
+
11
+
12
+ @utils.named_exception_handler("delete_schedule")
13
+ def main(schedule_id, dbname=None):
14
+ """Delete a schedule using schedule_id."""
15
+
16
+ db_conn = postgres.db_cicada(dbname)
17
+ db_cur = db_conn.cursor()
18
+ scheduler.delete_schedule(db_cur, str(schedule_id))
19
+ db_cur.close()
20
+ db_conn.close()
21
+
22
+ print("schedule_id '" + str(schedule_id) + "' is deleted!")
@@ -197,7 +197,6 @@ def main(schedule_id, dbname=None):
197
197
  db_conn = postgres.db_cicada(dbname)
198
198
  db_cur = db_conn.cursor()
199
199
  if get_abort_running(db_cur, schedule_id):
200
-
201
200
  # Terminate main process
202
201
  returncode = -15
203
202
  error_detail = "Cicada abort_running"
@@ -0,0 +1,19 @@
1
+ """List all schedule ID's."""
2
+
3
+ from tabulate import tabulate
4
+
5
+ from cicada.lib import postgres
6
+ from cicada.lib import scheduler
7
+ from cicada.lib import utils
8
+
9
+
10
+ @utils.named_exception_handler("list_schedule_ids")
11
+ def main(dbname=None):
12
+ """Show all Cicada schedule ID's."""
13
+ db_conn = postgres.db_cicada(dbname)
14
+ db_cur = db_conn.cursor()
15
+ obj_schedules = scheduler.get_all_schedule_ids(db_cur)
16
+ db_cur.close()
17
+ db_conn.close()
18
+ print("")
19
+ print(tabulate(obj_schedules, headers=["Server ID", "Schedule ID", "Description"]))
@@ -93,7 +93,6 @@ def main(spread_details, dbname=None):
93
93
  last_week_schedules_by_load = get_last_week_schedules_by_load(db_cur, from_server_ids)
94
94
 
95
95
  for schedule_id in last_week_schedules_by_load:
96
-
97
96
  current_schedule_details = scheduler.get_schedule_details(db_cur, schedule_id)
98
97
  new_schedule_details = current_schedule_details.copy()
99
98
  new_schedule_details["server_id"] = valid_target_servers[next_enabled_server]
@@ -28,7 +28,6 @@ def main(schedule_details, dbname=None):
28
28
  current_schedule_details = scheduler.get_schedule_details(db_cur, schedule_details["schedule_id"])
29
29
 
30
30
  if not current_schedule_details:
31
-
32
31
  if schedule_details["interval_mask"] is None:
33
32
  print("ERROR: interval_mask is required for new schedule")
34
33
  sys.exit(1)
cicada/lib/postgres.py CHANGED
@@ -1,4 +1,5 @@
1
1
  """Backend PostgreSQL database library"""
2
+
2
3
  # 2015-07-01 Louis Pieterse
3
4
 
4
5
  import psycopg2
@@ -18,7 +19,9 @@ def db_cicada(dbname=None):
18
19
  user = definitions["db_cicada"]["user"]
19
20
  password = definitions["db_cicada"]["password"]
20
21
 
21
- conn = psycopg2.connect(host=host, port=port, dbname=dbname, user=user, password=password)
22
+ conn = psycopg2.connect(
23
+ host=host, port=port, dbname=dbname, user=user, password=password, sslmode="require", application_name="cicada"
24
+ )
22
25
  conn.autocommit = True
23
26
 
24
27
  return conn
cicada/lib/scheduler.py CHANGED
@@ -25,7 +25,6 @@ def get_host_details():
25
25
  hostname = hostname[: hostname.find(".")]
26
26
 
27
27
  fqdn = socket.getfqdn()
28
-
29
28
  ip4_address = socket.gethostbyname(fqdn)
30
29
 
31
30
  host_details = {"hostname": hostname, "fqdn": fqdn, "ip4_address": ip4_address}
@@ -348,3 +347,17 @@ def get_all_schedules(db_cur, server_id, is_async):
348
347
  obj_schedules.append(schedule_id)
349
348
 
350
349
  return obj_schedules
350
+
351
+
352
+ def get_all_schedule_ids(db_cur):
353
+ sqlquery = "SELECT server_id, schedule_id, schedule_description from schedules"
354
+ db_cur.execute(sqlquery)
355
+ cur_schedules = db_cur
356
+
357
+ schedule_ids = cur_schedules.fetchall()
358
+ return schedule_ids
359
+
360
+
361
+ def delete_schedule(db_cur, schedule_id):
362
+ sqlquery = f"DELETE from schedules WHERE schedule_id = '{schedule_id}'"
363
+ db_cur.execute(sqlquery)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cicada
3
- Version: 0.6.0
3
+ Version: 0.8.3
4
4
  Summary: Lightweight, agent-based, distributed scheduler
5
5
  Home-page: https://github.com/transferwise/cicada
6
6
  Author: Wise
@@ -8,19 +8,19 @@ Classifier: License :: OSI Approved :: Apache Software License
8
8
  Classifier: Programming Language :: Python :: 3 :: Only
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
11
- Requires-Dist: psycopg2-binary (==2.9.5)
12
- Requires-Dist: pyyaml (==6.0)
13
- Requires-Dist: croniter (==1.3)
14
- Requires-Dist: tabulate (==0.9)
15
- Requires-Dist: slack-sdk (==3.19)
16
- Requires-Dist: backoff (==2.2)
11
+ Requires-Dist: psycopg2-binary ==2.9.*
12
+ Requires-Dist: pyyaml ==6.0.*
13
+ Requires-Dist: croniter ==2.0.*
14
+ Requires-Dist: tabulate ==0.9.*
15
+ Requires-Dist: slack-sdk ==3.31.*
16
+ Requires-Dist: backoff ==2.2.*
17
17
  Provides-Extra: dev
18
- Requires-Dist: pytest (==7.3) ; extra == 'dev'
19
- Requires-Dist: pytest-cov (==4.0) ; extra == 'dev'
20
- Requires-Dist: pytest-mock (==3.10) ; extra == 'dev'
21
- Requires-Dist: black (==22.12) ; extra == 'dev'
22
- Requires-Dist: flake8 (==6.0) ; extra == 'dev'
23
- Requires-Dist: freezegun (==1.2) ; extra == 'dev'
18
+ Requires-Dist: pytest ==8.2.* ; extra == 'dev'
19
+ Requires-Dist: pytest-cov ==5.0.* ; extra == 'dev'
20
+ Requires-Dist: pytest-mock ==3.14.* ; extra == 'dev'
21
+ Requires-Dist: black ==24.4.* ; extra == 'dev'
22
+ Requires-Dist: flake8 ==7.1.* ; extra == 'dev'
23
+ Requires-Dist: freezegun ==1.5.* ; extra == 'dev'
24
24
 
25
25
  # Cicada scheduler
26
26
 
@@ -0,0 +1,24 @@
1
+ cicada/__init__.py,sha256=3PATrC60ZHrUA8gAg8oiZGrtrQ7bWHp7VeYfp3pyaVg,30
2
+ cicada/cli.py,sha256=-2XcWtwRIx8tb0cisdhBT6MFue8ANCOsVrQNIqme_9s,10148
3
+ cicada/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ cicada/commands/archive_schedule_log.py,sha256=S0qcFajRcwtXMlOTPkHduXqdHQspzM046UAQxN8oPVo,2231
5
+ cicada/commands/delete_schedule.py,sha256=iNoE243gX9M3bBxOsgiusga5At5UnXIUpHkElsNz8-w,548
6
+ cicada/commands/exec_schedule.py,sha256=ywQEPPBKjzUe2S6Di45F1Iir7TblJ4bnd3psP9oCKMQ,8868
7
+ cicada/commands/exec_server_schedules.py,sha256=5TyDsQiUH9dx59GLO33aekSoUNO7g_HcHVvJW1yLjj8,1240
8
+ cicada/commands/list_schedules.py,sha256=vzRQVAs2yzsuyGV9yeQEpgmvFL5zIZlyMT-jbR7AybA,545
9
+ cicada/commands/list_server_schedules.py,sha256=-uxikgecitRh8YYe0WgL1AOLO6cfow1_lqmPeSVz4xE,1910
10
+ cicada/commands/ping_slack.py,sha256=fHOK6QjD7FfP7xa-XYuEuYAF6U5iojQkAkf9Qd66vfs,211
11
+ cicada/commands/register_server.py,sha256=OfOj72nqs0kMqzLKfscvRb8orWeuiYCke1-md0ng-nQ,656
12
+ cicada/commands/show_schedule.py,sha256=fC7jRFN5xrhKEq-9N_evEdBavbS7KtQ5dfgg4IWAPl8,769
13
+ cicada/commands/spread_schedules.py,sha256=N8ni0n9mFKenC4iiBgw7X9QPV3XZf9L0u5sKvUbajH8,4507
14
+ cicada/commands/upsert_schedule.py,sha256=pacujqNF7lzgHCG9XR4JkSlitV1s99par9hA-dMul8o,3740
15
+ cicada/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ cicada/lib/postgres.py,sha256=HEkz_-NPlBFCks3hoqXhrEndYkr8hDRui-NQWFHMqXo,882
17
+ cicada/lib/scheduler.py,sha256=oAidM2NgkOqQ6QzbAA2x-4lVA9K4pJMsPvm-hECgxo8,13201
18
+ cicada/lib/utils.py,sha256=qlXe6DnKJTqrdWeIuj_0fEQ-VhMJSzentf28KV-7uOs,2247
19
+ cicada-0.8.3.dist-info/LICENSE,sha256=jj_FHHgRjgQBUlPrrRsnr50zEOAhlg6gqU7mEqisyB0,10844
20
+ cicada-0.8.3.dist-info/METADATA,sha256=KO_Q3LkN2zfFmY3P5FwWnjUwzs3DaBui3Bh9DqS0XPA,5669
21
+ cicada-0.8.3.dist-info/WHEEL,sha256=-oYQCr74JF3a37z2nRlQays_SX2MqOANoqVjBBAP2yE,91
22
+ cicada-0.8.3.dist-info/entry_points.txt,sha256=Dzf3ul9hWITR4nfTDyNCtFTcQOOE57mD1x2qVniUWdE,43
23
+ cicada-0.8.3.dist-info/top_level.txt,sha256=xZCtaMDbCi2CKA5PExum99ZU54IJg5iognV-k44a1W0,7
24
+ cicada-0.8.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: setuptools (71.0.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,22 +0,0 @@
1
- cicada/__init__.py,sha256=3PATrC60ZHrUA8gAg8oiZGrtrQ7bWHp7VeYfp3pyaVg,30
2
- cicada/cli.py,sha256=DJlC7hWZeVO70gTMVR4tF7l42AswVZK1xoSG87nmkC0,8786
3
- cicada/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- cicada/commands/archive_schedule_log.py,sha256=S0qcFajRcwtXMlOTPkHduXqdHQspzM046UAQxN8oPVo,2231
5
- cicada/commands/exec_schedule.py,sha256=Ou1YF-gmX58NIPECL71yGerFYD12545YpBVctnd8e-o,8869
6
- cicada/commands/exec_server_schedules.py,sha256=5TyDsQiUH9dx59GLO33aekSoUNO7g_HcHVvJW1yLjj8,1240
7
- cicada/commands/list_server_schedules.py,sha256=-uxikgecitRh8YYe0WgL1AOLO6cfow1_lqmPeSVz4xE,1910
8
- cicada/commands/ping_slack.py,sha256=fHOK6QjD7FfP7xa-XYuEuYAF6U5iojQkAkf9Qd66vfs,211
9
- cicada/commands/register_server.py,sha256=OfOj72nqs0kMqzLKfscvRb8orWeuiYCke1-md0ng-nQ,656
10
- cicada/commands/show_schedule.py,sha256=fC7jRFN5xrhKEq-9N_evEdBavbS7KtQ5dfgg4IWAPl8,769
11
- cicada/commands/spread_schedules.py,sha256=f1A8XlPMJjVVoyY-BkV59ecoyhOOsueQBuD77caea4o,4508
12
- cicada/commands/upsert_schedule.py,sha256=wsypHmTaFvldDqMeC7jiPJ0vcA106_56WDZRVMODt_4,3741
13
- cicada/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- cicada/lib/postgres.py,sha256=OhZmr0w4B4ktV3Sev3ybr7l7mcG6XKhcvkwQT1IVwes,821
15
- cicada/lib/scheduler.py,sha256=egw03V9Evt7e89J8_GaCMQE6XTwX3hAaIXJ5yKIsIzs,12808
16
- cicada/lib/utils.py,sha256=qlXe6DnKJTqrdWeIuj_0fEQ-VhMJSzentf28KV-7uOs,2247
17
- cicada-0.6.0.dist-info/LICENSE,sha256=jj_FHHgRjgQBUlPrrRsnr50zEOAhlg6gqU7mEqisyB0,10844
18
- cicada-0.6.0.dist-info/METADATA,sha256=KDqJCYZF3WNfontvMs_ahbFWg8X1wn8N0n70f7HXzTE,5672
19
- cicada-0.6.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
20
- cicada-0.6.0.dist-info/entry_points.txt,sha256=Dzf3ul9hWITR4nfTDyNCtFTcQOOE57mD1x2qVniUWdE,43
21
- cicada-0.6.0.dist-info/top_level.txt,sha256=xZCtaMDbCi2CKA5PExum99ZU54IJg5iognV-k44a1W0,7
22
- cicada-0.6.0.dist-info/RECORD,,