gomyck-tools 1.1.4__tar.gz → 1.1.5__tar.gz

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.
Files changed (62) hide show
  1. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/PKG-INFO +1 -1
  2. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/ckafka.py +9 -9
  3. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/id_worker_tools.py +2 -14
  4. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/gomyck_tools.egg-info/PKG-INFO +1 -1
  5. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/setup.py +1 -1
  6. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/README.md +0 -0
  7. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/__init__.py +0 -0
  8. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/aes_tools.py +0 -0
  9. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/api_result.py +0 -0
  10. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/application.py +0 -0
  11. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/b64.py +0 -0
  12. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/bashPath.py +0 -0
  13. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/bottle_web_base.py +0 -0
  14. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/bottle_webserver.py +0 -0
  15. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/bottle_websocket.py +0 -0
  16. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/browser_element_tools.py +0 -0
  17. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/call.py +0 -0
  18. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/cjson.py +0 -0
  19. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/compile_tools.py +0 -0
  20. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/console.py +0 -0
  21. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/cron_lite.py +0 -0
  22. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/database.py +0 -0
  23. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/date_utils.py +0 -0
  24. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/dict_wrapper.py +0 -0
  25. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/douglas_rarefy.py +0 -0
  26. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/download_tools.py +0 -0
  27. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/enums.py +0 -0
  28. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/ex.py +0 -0
  29. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/excelOpt.py +0 -0
  30. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/html_soup.py +0 -0
  31. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/http_utils.py +0 -0
  32. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/images_tools.py +0 -0
  33. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/imgDialog.py +0 -0
  34. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/license.py +0 -0
  35. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/metrics.py +0 -0
  36. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/mqtt_utils.py +0 -0
  37. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/obj.py +0 -0
  38. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/pacth.py +0 -0
  39. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/plan_area_tools.py +0 -0
  40. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/process_pool.py +0 -0
  41. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/pty_tools.py +0 -0
  42. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/resource_bundle_tools.py +0 -0
  43. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/screenshot_tools.py +0 -0
  44. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/sign.py +0 -0
  45. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/sm_tools.py +0 -0
  46. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/strDiff.py +0 -0
  47. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/string_tools.py +0 -0
  48. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/sys_info.py +0 -0
  49. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/sys_log.py +0 -0
  50. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/thread_pool.py +0 -0
  51. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/upload_tools.py +0 -0
  52. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/win_canvas.py +0 -0
  53. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/win_control.py +0 -0
  54. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/wordFill.py +0 -0
  55. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/word_fill.py +0 -0
  56. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/word_fill_entity.py +0 -0
  57. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/ctools/work_path.py +0 -0
  58. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/gomyck_tools.egg-info/SOURCES.txt +0 -0
  59. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/gomyck_tools.egg-info/dependency_links.txt +0 -0
  60. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/gomyck_tools.egg-info/requires.txt +0 -0
  61. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/gomyck_tools.egg-info/top_level.txt +0 -0
  62. {gomyck-tools-1.1.4 → gomyck-tools-1.1.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gomyck-tools
3
- Version: 1.1.4
3
+ Version: 1.1.5
4
4
  Summary: A ctools for python development by hao474798383
5
5
  Home-page: https://blog.gomyck.com
6
6
  Author: gomyck
@@ -66,7 +66,7 @@ class KafkaInstance:
66
66
  self.consumer.subscribe(self.consumer_callback.keys())
67
67
  self.consumer_callback[topic].append(callBack)
68
68
  if not self.start_consumer:
69
- t = Thread(target=self._start_consumer_poll, daemon=True)
69
+ t = Thread(target=self._start_consumer_poll, daemon=False)
70
70
  t.start()
71
71
 
72
72
  def _start_consumer_poll(self):
@@ -101,7 +101,7 @@ class CKafka:
101
101
  self.password = password
102
102
 
103
103
  def init_producer(self, acks=1) -> KafkaInstance:
104
- print("[ Producer ] Connecting to Kafka brokers")
104
+ print("[ Producer ] Connecting to Kafka [{}]".format(self.kafka_url))
105
105
  for i in range(0, 6):
106
106
  try:
107
107
  if self.secure:
@@ -120,15 +120,15 @@ class CKafka:
120
120
  bootstrap_servers=self.kafka_url,
121
121
  value_serializer=lambda x: dumps(x).encode('utf-8')
122
122
  )
123
- print("[ Producer ] Connected to Kafka...")
123
+ print("[ Producer ] Success Connected to Kafka [{}]".format(self.kafka_url))
124
124
  return KafkaInstance(producer=producer, consumer=None)
125
125
  except errors.NoBrokersAvailable:
126
- print("[ Producer ] Waiting for brokers to become available...")
126
+ print("[ Producer ] Waiting for Kafka [{}] to become available...".format(self.kafka_url))
127
127
  time.sleep(3)
128
- raise RuntimeError("[ Producer ] Failed to connect to brokers within 60 seconds")
128
+ raise RuntimeError("[ Producer ] Failed to connect to Kafka [{}] within 60 seconds".format(self.kafka_url))
129
129
 
130
130
  def init_consumer(self, client_id: str = 'ck-py-kafka-consumer', consumer_group: str = 'ck-py-kafka-consumer', enable_auto_commit: bool = True) -> KafkaInstance:
131
- print("[ Consumer ] Connecting to Kafka brokers")
131
+ print("[ Consumer ] Connecting to Kafka [{}]".format(self.kafka_url))
132
132
  for i in range(0, 6):
133
133
  try:
134
134
  if self.secure:
@@ -151,9 +151,9 @@ class CKafka:
151
151
  bootstrap_servers=self.kafka_url,
152
152
  value_deserializer=lambda x: x.decode('utf-8')
153
153
  )
154
- print("[ Consumer ] Connected to Kafka...")
154
+ print("[ Consumer ] Success Connected to Kafka [{}]".format(self.kafka_url))
155
155
  return KafkaInstance(producer=None, consumer=consumer)
156
156
  except errors.NoBrokersAvailable:
157
- print("[ Consumer ] Waiting for brokers to become available...")
157
+ print("[ Consumer ] Waiting for Kafka [{}] to become available...".format(self.kafka_url))
158
158
  time.sleep(3)
159
- raise RuntimeError("[ Consumer ] Failed to connect to brokers within 60 seconds")
159
+ raise RuntimeError("[ Consumer ] Failed to connect to Kafka [{}] within 60 seconds".format(self.kafka_url))
@@ -4,28 +4,22 @@ import time
4
4
  WORKER_ID_BITS = 5
5
5
  DATACENTER_ID_BITS = 5
6
6
  SEQUENCE_BITS = 12
7
-
8
7
  # 最大取值计算
9
8
  MAX_WORKER_ID = -1 ^ (-1 << WORKER_ID_BITS) # 2**5-1 0b11111
10
9
  MAX_DATACENTER_ID = -1 ^ (-1 << DATACENTER_ID_BITS)
11
-
12
10
  # 移位偏移计算
13
11
  WOKER_ID_SHIFT = SEQUENCE_BITS
14
12
  DATACENTER_ID_SHIFT = SEQUENCE_BITS + WORKER_ID_BITS
15
13
  TIMESTAMP_LEFT_SHIFT = SEQUENCE_BITS + WORKER_ID_BITS + DATACENTER_ID_BITS
16
-
17
14
  # 序号循环掩码
18
15
  SEQUENCE_MASK = -1 ^ (-1 << SEQUENCE_BITS)
19
-
20
16
  # Twitter元年时间戳
21
17
  TWEPOCH = 1288834974657
22
18
 
23
-
24
19
  class IdWorker(object):
25
20
  """
26
21
  用于生成IDs
27
22
  """
28
-
29
23
  def __init__(self, datacenter_id, worker_id, sequence=0):
30
24
  """
31
25
  初始化
@@ -36,17 +30,15 @@ class IdWorker(object):
36
30
  # sanity check
37
31
  if worker_id > MAX_WORKER_ID or worker_id < 0:
38
32
  raise ValueError('worker_id值越界')
39
-
40
33
  if datacenter_id > MAX_DATACENTER_ID or datacenter_id < 0:
41
34
  raise ValueError('datacenter_id值越界')
42
-
43
35
  self.worker_id = worker_id
44
36
  self.datacenter_id = datacenter_id
45
37
  self.sequence = sequence
46
-
47
38
  self.last_timestamp = -1 # 上次计算的时间戳
48
39
 
49
- def _gen_timestamp(self):
40
+ @staticmethod
41
+ def _gen_timestamp():
50
42
  """
51
43
  生成整数时间戳
52
44
  :return:int timestamp
@@ -59,21 +51,17 @@ class IdWorker(object):
59
51
  :return:
60
52
  """
61
53
  timestamp = self._gen_timestamp()
62
-
63
54
  # 时钟回拨
64
55
  if timestamp < self.last_timestamp:
65
56
  print('clock is moving backwards. Rejecting requests until {}'.format(self.last_timestamp))
66
57
  raise
67
-
68
58
  if timestamp == self.last_timestamp:
69
59
  self.sequence = (self.sequence + 1) & SEQUENCE_MASK
70
60
  if self.sequence == 0:
71
61
  timestamp = self._til_next_millis(self.last_timestamp)
72
62
  else:
73
63
  self.sequence = 0
74
-
75
64
  self.last_timestamp = timestamp
76
-
77
65
  new_id = ((timestamp - TWEPOCH) << TIMESTAMP_LEFT_SHIFT) | (self.datacenter_id << DATACENTER_ID_SHIFT) | \
78
66
  (self.worker_id << WOKER_ID_SHIFT) | self.sequence
79
67
  return new_id
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gomyck-tools
3
- Version: 1.1.4
3
+ Version: 1.1.5
4
4
  Summary: A ctools for python development by hao474798383
5
5
  Home-page: https://blog.gomyck.com
6
6
  Author: gomyck
@@ -11,7 +11,7 @@ requirements = parse_requirements(os.path.join(os.path.dirname(__file__), 'requi
11
11
 
12
12
  setup(
13
13
  name="gomyck-tools",
14
- version="1.1.4",
14
+ version="1.1.5",
15
15
  author="gomyck",
16
16
  author_email="hao474798383@163.com",
17
17
  description="A ctools for python development by hao474798383",
File without changes
File without changes
File without changes
File without changes
File without changes