python3-cyberfusion-queue-support 3.0.3__py3-none-any.whl → 3.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.
@@ -104,9 +104,7 @@ class QueueProcess(BaseModel):
104
104
  __tablename__ = "queue_processes"
105
105
 
106
106
  queue_id = Column(
107
- Integer,
108
- ForeignKey("queues.id", ondelete="CASCADE"),
109
- nullable=False,
107
+ Integer, ForeignKey("queues.id", ondelete="CASCADE"), nullable=False, index=True
110
108
  )
111
109
  preview = Column(Boolean, nullable=False)
112
110
  status = Column(Enum(QueueProcessStatus), nullable=True)
@@ -125,9 +123,7 @@ class QueueItem(BaseModel):
125
123
  __tablename__ = "queue_items"
126
124
 
127
125
  queue_id = Column(
128
- Integer,
129
- ForeignKey("queues.id", ondelete="CASCADE"),
130
- nullable=False,
126
+ Integer, ForeignKey("queues.id", ondelete="CASCADE"), nullable=False, index=True
131
127
  )
132
128
  type = Column(String(length=255), nullable=False)
133
129
  reference = Column(String(length=255), nullable=True)
@@ -154,11 +150,13 @@ class QueueItemOutcome(BaseModel):
154
150
  Integer,
155
151
  ForeignKey("queue_items.id", ondelete="CASCADE"),
156
152
  nullable=False,
153
+ index=True,
157
154
  )
158
155
  queue_process_id = Column(
159
156
  Integer,
160
157
  ForeignKey("queue_processes.id", ondelete="CASCADE"),
161
158
  nullable=False,
159
+ index=True,
162
160
  )
163
161
  type = Column(String(length=255), nullable=False)
164
162
  attributes = Column(JSON, nullable=False)
@@ -7,27 +7,30 @@ from cyberfusion.QueueSupport.items import _Item
7
7
 
8
8
 
9
9
  class ItemError(Exception):
10
- """Issues with item."""
11
-
12
10
  pass
13
11
 
14
12
 
15
13
  @dataclass
16
14
  class PathIsSymlinkError(ItemError):
17
- """Path is symlink."""
15
+ path: str
18
16
 
17
+
18
+ @dataclass
19
+ class PathIsFileError(ItemError):
19
20
  path: str
20
21
 
21
22
 
22
23
  @dataclass
23
- class CommandQueueFulfillFailed(Exception):
24
- """Error occurred while fulfilling queue, with command item."""
24
+ class ParentNotFoundError(ItemError):
25
+ parent: str
26
+
25
27
 
28
+ @dataclass
29
+ class CommandQueueFulfillFailed(Exception):
26
30
  item: _Item
27
31
  command: List[str]
28
32
  stdout: str
29
33
  stderr: str
30
34
 
31
35
  def __str__(self) -> str:
32
- """Get string representation."""
33
36
  return f"Command:\n\n{self.command}\n\nStdout:\n\n{self.stdout}\n\nStderr:\n\n{self.stderr}"
@@ -2,9 +2,14 @@
2
2
 
3
3
  import logging
4
4
  import os
5
+ from pathlib import Path
5
6
  from typing import List, Optional
6
7
 
7
- from cyberfusion.QueueSupport.exceptions import PathIsSymlinkError
8
+ from cyberfusion.QueueSupport.exceptions import (
9
+ PathIsSymlinkError,
10
+ PathIsFileError,
11
+ ParentNotFoundError,
12
+ )
8
13
  from cyberfusion.QueueSupport.items import _Item
9
14
  from cyberfusion.QueueSupport.outcomes import MkdirItemCreateOutcome
10
15
 
@@ -18,30 +23,38 @@ class MkdirItem(_Item):
18
23
  self,
19
24
  *,
20
25
  path: str,
26
+ recursively: bool = False,
21
27
  reference: Optional[str] = None,
22
28
  hide_outcomes: bool = False,
23
29
  fail_silently: bool = False,
24
30
  ) -> None:
25
31
  """Set attributes."""
26
32
  self.path = path
33
+ self.recursively = recursively
27
34
  self._reference = reference
28
35
  self._hide_outcomes = hide_outcomes
29
36
  self._fail_silently = fail_silently
30
37
 
31
- if os.path.islink(self.path):
32
- raise PathIsSymlinkError(self.path)
33
-
34
38
  @property
35
39
  def outcomes(self) -> List[MkdirItemCreateOutcome]:
36
40
  """Get outcomes of item."""
37
41
  outcomes = []
38
42
 
39
- if not os.path.isdir(self.path):
40
- outcomes.append(
41
- MkdirItemCreateOutcome(
42
- path=self.path,
43
- )
44
- )
43
+ path_elements = list(reversed(Path(self.path).parents))
44
+ path_elements.append(Path(self.path))
45
+
46
+ for path in path_elements:
47
+ if os.path.islink(path):
48
+ raise PathIsSymlinkError(str(path))
49
+ elif os.path.isfile(path):
50
+ raise PathIsFileError(str(path))
51
+ elif os.path.isdir(path):
52
+ continue
53
+
54
+ if not self.recursively and str(path) != self.path:
55
+ raise ParentNotFoundError(str(path))
56
+
57
+ outcomes.append(MkdirItemCreateOutcome(path=str(path)))
45
58
 
46
59
  return outcomes
47
60
 
@@ -0,0 +1,52 @@
1
+ """Add indexes
2
+
3
+ Revision ID: 93c79cb2baba
4
+ Revises: 2f4316506856
5
+ Create Date: 2025-10-03 13:55:00.001141
6
+
7
+ """
8
+
9
+ from alembic import op
10
+
11
+
12
+ # revision identifiers, used by Alembic.
13
+ revision = "93c79cb2baba"
14
+ down_revision = "2f4316506856"
15
+ branch_labels = None
16
+ depends_on = None
17
+
18
+
19
+ def upgrade() -> None:
20
+ with op.batch_alter_table("queue_item_outcomes", schema=None) as batch_op:
21
+ batch_op.create_index(
22
+ batch_op.f("ix_queue_item_outcomes_queue_item_id"),
23
+ ["queue_item_id"],
24
+ unique=False,
25
+ )
26
+ batch_op.create_index(
27
+ batch_op.f("ix_queue_item_outcomes_queue_process_id"),
28
+ ["queue_process_id"],
29
+ unique=False,
30
+ )
31
+
32
+ with op.batch_alter_table("queue_items", schema=None) as batch_op:
33
+ batch_op.create_index(
34
+ batch_op.f("ix_queue_items_queue_id"), ["queue_id"], unique=False
35
+ )
36
+
37
+ with op.batch_alter_table("queue_processes", schema=None) as batch_op:
38
+ batch_op.create_index(
39
+ batch_op.f("ix_queue_processes_queue_id"), ["queue_id"], unique=False
40
+ )
41
+
42
+
43
+ def downgrade() -> None:
44
+ with op.batch_alter_table("queue_processes", schema=None) as batch_op:
45
+ batch_op.drop_index(batch_op.f("ix_queue_processes_queue_id"))
46
+
47
+ with op.batch_alter_table("queue_items", schema=None) as batch_op:
48
+ batch_op.drop_index(batch_op.f("ix_queue_items_queue_id"))
49
+
50
+ with op.batch_alter_table("queue_item_outcomes", schema=None) as batch_op:
51
+ batch_op.drop_index(batch_op.f("ix_queue_item_outcomes_queue_process_id"))
52
+ batch_op.drop_index(batch_op.f("ix_queue_item_outcomes_queue_item_id"))
@@ -483,19 +483,6 @@ class DatabaseUserEnsureStateItemEditPasswordOutcome(OutcomeInterface):
483
483
  if not isinstance(other, DatabaseUserEnsureStateItemEditPasswordOutcome):
484
484
  return False
485
485
 
486
- print(
487
- other.database_user.server_software_name,
488
- other.database_user.name,
489
- other.database_user.password,
490
- other.database_user.host,
491
- )
492
- print(
493
- self.database_user.server_software_name,
494
- self.database_user.name,
495
- self.database_user.password,
496
- self.database_user.host,
497
- )
498
-
499
486
  return (
500
487
  other.database_user.server_software_name
501
488
  == self.database_user.server_software_name
@@ -11,11 +11,8 @@ def main() -> None:
11
11
  days=settings.queue_purge_days
12
12
  )
13
13
 
14
- queues = (
15
- database_session.query(Queue).filter(Queue.created_at < purge_before_date).all()
16
- )
14
+ queues = database_session.query(Queue).filter(Queue.created_at < purge_before_date)
17
15
 
18
- for queue in queues:
19
- database_session.delete(queue)
16
+ queues.delete()
20
17
 
21
18
  database_session.commit()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python3-cyberfusion-queue-support
3
- Version: 3.0.3
3
+ Version: 3.2
4
4
  Summary: Library to queue actions.
5
5
  Author-email: Cyberfusion <support@cyberfusion.io>
6
6
  Project-URL: Source, https://github.com/CyberfusionIO/python3-cyberfusion-queue-support
@@ -1,13 +1,13 @@
1
1
  cyberfusion/QueueSupport/__init__.py,sha256=KvLhTLBUE3aUMc-HetRzAgPxYNIvnJ4sixqbw0WVuVo,4836
2
- cyberfusion/QueueSupport/database.py,sha256=cAFG587-ljpsbBq9hnyqWxy4IHkllH1KptLmzA5TQmo,4711
2
+ cyberfusion/QueueSupport/database.py,sha256=SRGHi0MJ7GerGcKOvEpu4lp82OfYf-Ev_eZeJ1PmexM,4741
3
3
  cyberfusion/QueueSupport/encoders.py,sha256=SzuMoyr2q3ME8LI_bZtpP76Xg7SP0B4O4uUuywrDwBI,1532
4
4
  cyberfusion/QueueSupport/enums.py,sha256=XzOy5J4sa7SOCKNFyw9kw3MyqDkjPookbfiMQHRHGfQ,122
5
5
  cyberfusion/QueueSupport/interfaces.py,sha256=ip8z6cfLFldQCDSec6fK6AIOdxOjIyFykDv4dCHJYSI,943
6
- cyberfusion/QueueSupport/outcomes.py,sha256=MjvhjfEu2rACvgZfAsjtmVPOUonuhyVhAuV5HuJDvgI,18903
6
+ cyberfusion/QueueSupport/outcomes.py,sha256=M1qkxSBxrNFZMZJAmdiixmFo6peWFrVL9ka7l1AdnUI,18512
7
7
  cyberfusion/QueueSupport/sentinels.py,sha256=LwD1BUxDJgY6aJr21cunZKRn5nycqqlNlmJhFKjqUBw,57
8
8
  cyberfusion/QueueSupport/settings.py,sha256=UL0WDxK7W6N--SdhKwkSQf1b3ZKstzxMirZzpyjgefE,289
9
9
  cyberfusion/QueueSupport/utilities.py,sha256=vsQOZunX0UwudoIauCPV-Ij1TVrjWG_16wctvJPaMVQ,186
10
- cyberfusion/QueueSupport/exceptions/__init__.py,sha256=2YAEQg8bsAMHq184ZCggNogaY3gsUv7Zym1EXAPSG-I,657
10
+ cyberfusion/QueueSupport/exceptions/__init__.py,sha256=MfSC7X751Kbe1lhQAcUeX3LIUlUOfBoAtFNUIFWrQNo,618
11
11
  cyberfusion/QueueSupport/items/__init__.py,sha256=_2nJSRRDofe-whGZOLzp0SXoafZNYP6GAh8DVBNj5Jg,1077
12
12
  cyberfusion/QueueSupport/items/chmod.py,sha256=jkS3hkmMxgUpPumhK1DfiR6YQ-gZBKmaizwObdjF_7o,2122
13
13
  cyberfusion/QueueSupport/items/chown.py,sha256=8NGg4p6r9Jl03jC1Z2J2EBdUVFjgV0nXVmlw0YZIS2k,4135
@@ -19,7 +19,7 @@ cyberfusion/QueueSupport/items/database_user_drop.py,sha256=KrWbRYD7CzoxkHVVo82g
19
19
  cyberfusion/QueueSupport/items/database_user_ensure_state.py,sha256=kJC6be3bnWuw-yKhb2BqIumAXPMRvyPgIu4Rt4timE4,3022
20
20
  cyberfusion/QueueSupport/items/database_user_grant_grant.py,sha256=hZ6xv0CSBrCcxjX5OKje66CnzCDGp8Melx-JmfZUFc4,3773
21
21
  cyberfusion/QueueSupport/items/database_user_grant_revoke.py,sha256=njD8TdEukco4JIg71L-cBYsl2g0Tzt9J6LUd3Xbcd5s,3780
22
- cyberfusion/QueueSupport/items/mkdir.py,sha256=FJZ1KuAMbnRDV8voDfN0ESNb-85A_hT-N8JJjNR5u4k,1560
22
+ cyberfusion/QueueSupport/items/mkdir.py,sha256=hK7l8crazhT9KWozrMlzx6NlHjjIIMFLYioUyrqIuQ0,2022
23
23
  cyberfusion/QueueSupport/items/move.py,sha256=0JzuQdQ7DU3jXmF0xziE8G_SXQqQsWI95QUVWva11zM,1750
24
24
  cyberfusion/QueueSupport/items/rmtree.py,sha256=WtrdU8ehE2oT43RCYaUQhW2amZKSt1_Oxy5op5bMrHU,2007
25
25
  cyberfusion/QueueSupport/items/systemd_daemon_reload.py,sha256=MTHp3ypnyFh5y23lYKKS8wCLHQ4-HRRstImStubpPXE,1363
@@ -39,12 +39,13 @@ cyberfusion/QueueSupport/migrations/versions/52d1b17abcd0_add_status.py,sha256=g
39
39
  cyberfusion/QueueSupport/migrations/versions/571e55ab5ed5_initial_migration.py,sha256=1yYFZhQyHVnn1nHXxLVRb94V7gXprWYMfIDhF0_DPVU,2845
40
40
  cyberfusion/QueueSupport/migrations/versions/8023b9eecdd1_add_traceback_to_queue_items.py,sha256=IfwqqHeE6e4iDH3bc6FrOgdBT4w-Kxa2MYv0dzYjEbk,497
41
41
  cyberfusion/QueueSupport/migrations/versions/8406a0af7394_set_status_on_existing_queue_processes.py,sha256=fhfeErva3B3rrmr6-cbGO8DrjXU6qp1sIzVJGzOJ7iI,424
42
+ cyberfusion/QueueSupport/migrations/versions/93c79cb2baba_add_indexes.py,sha256=raIrgSg6b4CboiSvtzhBy7q7kuREb8FeYKCUtBTaYbM,1651
42
43
  cyberfusion/QueueSupport/migrations/versions/9ae29b5db790_add_string_to_queue_item_outcomes.py,sha256=CzNJVL5Ia_J5woGsnCRSrlraoaT8YfgZUVOlAWHjb2Y,546
43
44
  cyberfusion/QueueSupport/migrations/versions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
45
  cyberfusion/QueueSupport/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
- cyberfusion/QueueSupport/scripts/purge_queues.py,sha256=0i77UEK_dzCof0I3wF0zagc6FXhx3obv7x5Ocju3i0M,539
46
- python3_cyberfusion_queue_support-3.0.3.dist-info/METADATA,sha256=qhFQy3jmqk-DIifaDHuEaze4-lIBGYeEbmDycDBoFLA,4621
47
- python3_cyberfusion_queue_support-3.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
- python3_cyberfusion_queue_support-3.0.3.dist-info/entry_points.txt,sha256=z7WykKo9hbm5I1iMbHIearPGdkGemhQnSkl7a44zMDY,171
49
- python3_cyberfusion_queue_support-3.0.3.dist-info/top_level.txt,sha256=ss011q9S6SL_KIIyq7iujFmIYa0grSjlnInO7cDkeag,12
50
- python3_cyberfusion_queue_support-3.0.3.dist-info/RECORD,,
46
+ cyberfusion/QueueSupport/scripts/purge_queues.py,sha256=W1-p85YhAJhJfHIPQrS0KVgrLMzWPlGniDTZ_dSma_w,473
47
+ python3_cyberfusion_queue_support-3.2.dist-info/METADATA,sha256=0YfuZGV2z_sx_gWT4gy5vOm3fkHXQv0EJt96M0hPN94,4619
48
+ python3_cyberfusion_queue_support-3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
+ python3_cyberfusion_queue_support-3.2.dist-info/entry_points.txt,sha256=z7WykKo9hbm5I1iMbHIearPGdkGemhQnSkl7a44zMDY,171
50
+ python3_cyberfusion_queue_support-3.2.dist-info/top_level.txt,sha256=ss011q9S6SL_KIIyq7iujFmIYa0grSjlnInO7cDkeag,12
51
+ python3_cyberfusion_queue_support-3.2.dist-info/RECORD,,