cicada 0.5.1__py3-none-any.whl → 0.8.2__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 +39 -0
- cicada/commands/delete_schedule.py +22 -0
- cicada/commands/exec_schedule.py +0 -1
- cicada/commands/list_schedules.py +19 -0
- cicada/commands/spread_schedules.py +0 -1
- cicada/commands/upsert_schedule.py +0 -1
- cicada/lib/postgres.py +2 -1
- cicada/lib/scheduler.py +15 -2
- {cicada-0.5.1.dist-info → cicada-0.8.2.dist-info}/METADATA +13 -13
- cicada-0.8.2.dist-info/RECORD +24 -0
- {cicada-0.5.1.dist-info → cicada-0.8.2.dist-info}/WHEEL +1 -1
- cicada-0.5.1.dist-info/RECORD +0 -22
- {cicada-0.5.1.dist-info → cicada-0.8.2.dist-info}/LICENSE +0 -0
- {cicada-0.5.1.dist-info → cicada-0.8.2.dist-info}/entry_points.txt +0 -0
- {cicada-0.5.1.dist-info → cicada-0.8.2.dist-info}/top_level.txt +0 -0
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!")
|
cicada/commands/exec_schedule.py
CHANGED
@@ -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,7 @@ 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(host=host, port=port, dbname=dbname, user=user, password=password, sslmode="prefer")
|
22
23
|
conn.autocommit = True
|
23
24
|
|
24
25
|
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}
|
@@ -153,7 +152,7 @@ def insert_schedule_details(db_cur, schedule_details):
|
|
153
152
|
if schedule_details["schedule_description"] is not None:
|
154
153
|
sqlquery = sqlquery + " ,'" + str(schedule_details["schedule_description"]) + "'"
|
155
154
|
if schedule_details["server_id"] is None:
|
156
|
-
sqlquery = sqlquery + " ,(SELECT
|
155
|
+
sqlquery = sqlquery + " ,(SELECT MAX(server_id) FROM servers WHERE is_enabled=1)"
|
157
156
|
else:
|
158
157
|
sqlquery = sqlquery + " ," + str(schedule_details["server_id"])
|
159
158
|
if schedule_details["schedule_order"] is not None:
|
@@ -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.
|
3
|
+
Version: 0.8.2
|
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
|
12
|
-
Requires-Dist: pyyaml
|
13
|
-
Requires-Dist: croniter
|
14
|
-
Requires-Dist: tabulate
|
15
|
-
Requires-Dist: slack-sdk
|
16
|
-
Requires-Dist: backoff
|
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.30.*
|
16
|
+
Requires-Dist: backoff ==2.2.*
|
17
17
|
Provides-Extra: dev
|
18
|
-
Requires-Dist: pytest
|
19
|
-
Requires-Dist: pytest-cov
|
20
|
-
Requires-Dist: pytest-mock
|
21
|
-
Requires-Dist: black
|
22
|
-
Requires-Dist: flake8
|
23
|
-
Requires-Dist: freezegun
|
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=DTPKRNYTi5yMC6xPPhX2l4U8hpSfTfciE77pfjd_H24,840
|
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.2.dist-info/LICENSE,sha256=jj_FHHgRjgQBUlPrrRsnr50zEOAhlg6gqU7mEqisyB0,10844
|
20
|
+
cicada-0.8.2.dist-info/METADATA,sha256=iBxdfaTSf6akdljQvj3nAHNNjBQYAQd01YTqZ0LSs9E,5669
|
21
|
+
cicada-0.8.2.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
|
22
|
+
cicada-0.8.2.dist-info/entry_points.txt,sha256=Dzf3ul9hWITR4nfTDyNCtFTcQOOE57mD1x2qVniUWdE,43
|
23
|
+
cicada-0.8.2.dist-info/top_level.txt,sha256=xZCtaMDbCi2CKA5PExum99ZU54IJg5iognV-k44a1W0,7
|
24
|
+
cicada-0.8.2.dist-info/RECORD,,
|
cicada-0.5.1.dist-info/RECORD
DELETED
@@ -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=qzh_Xx0l86B9GkXzWCnkIIGkdh9p2RmiKIoSS6s6auE,12808
|
16
|
-
cicada/lib/utils.py,sha256=qlXe6DnKJTqrdWeIuj_0fEQ-VhMJSzentf28KV-7uOs,2247
|
17
|
-
cicada-0.5.1.dist-info/LICENSE,sha256=jj_FHHgRjgQBUlPrrRsnr50zEOAhlg6gqU7mEqisyB0,10844
|
18
|
-
cicada-0.5.1.dist-info/METADATA,sha256=Qx7VUcL1ckL3TGDOmu5hcpSYzc5RJ4G-55vM1c9X9lY,5692
|
19
|
-
cicada-0.5.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
20
|
-
cicada-0.5.1.dist-info/entry_points.txt,sha256=Dzf3ul9hWITR4nfTDyNCtFTcQOOE57mD1x2qVniUWdE,43
|
21
|
-
cicada-0.5.1.dist-info/top_level.txt,sha256=xZCtaMDbCi2CKA5PExum99ZU54IJg5iognV-k44a1W0,7
|
22
|
-
cicada-0.5.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|