solax-py-library 1.0.0.8__tar.gz → 1.0.0.10__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 (23) hide show
  1. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/PKG-INFO +2 -3
  2. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/README.md +1 -2
  3. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/pyproject.toml +1 -1
  4. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/core/upload_service/ftp.py +3 -1
  5. solax_py_library-1.0.0.10/solax_py_library/upload/test/test_ftp.py +40 -0
  6. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/types/ftp.py +2 -1
  7. solax_py_library-1.0.0.8/solax_py_library/upload/test/test_ftp.py +0 -37
  8. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/__init__.py +0 -0
  9. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/__init__.py +0 -0
  10. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/api/__init__.py +0 -0
  11. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/api/service.py +0 -0
  12. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/core/__init__.py +0 -0
  13. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/core/data_adapter/__init__.py +0 -0
  14. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/core/data_adapter/base.py +0 -0
  15. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/core/data_adapter/csv.py +0 -0
  16. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/core/upload_service/__init__.py +0 -0
  17. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/core/upload_service/base.py +0 -0
  18. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/errors/__init__.py +0 -0
  19. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/errors/base.py +0 -0
  20. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/errors/upload_error.py +0 -0
  21. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/test/__init__.py +0 -0
  22. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/types/__init__.py +0 -0
  23. {solax_py_library-1.0.0.8 → solax_py_library-1.0.0.10}/solax_py_library/upload/types/client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: solax-py-library
3
- Version: 1.0.0.8
3
+ Version: 1.0.0.10
4
4
  Summary: some common tool
5
5
  Author: shenlvyu
6
6
  Author-email: 13296718439@163.com
@@ -40,7 +40,7 @@ This package provide some general modules to help us can focus on the real proje
40
40
  - upload: The module define the upload tool.It support the way by Ftp.
41
41
 
42
42
 
43
- #### quick start
43
+ #### quick start
44
44
 
45
45
  ```python
46
46
  await upload(
@@ -66,4 +66,3 @@ await upload(
66
66
  )
67
67
  ```
68
68
 
69
-
@@ -22,7 +22,7 @@ This package provide some general modules to help us can focus on the real proje
22
22
  - upload: The module define the upload tool.It support the way by Ftp.
23
23
 
24
24
 
25
- #### quick start
25
+ #### quick start
26
26
 
27
27
  ```python
28
28
  await upload(
@@ -47,4 +47,3 @@ await upload(
47
47
  ),
48
48
  )
49
49
  ```
50
-
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "solax-py-library"
3
- version = "1.0.0.8"
3
+ version = "1.0.0.10"
4
4
  description = "some common tool"
5
5
  authors = ["shenlvyu <13296718439@163.com>"]
6
6
  readme = "README.md"
@@ -24,6 +24,7 @@ class FTPUploadService(BaseUploadService):
24
24
  super().__init__(**kwargs)
25
25
  config = self._init_config(**kwargs)
26
26
  self.host = config.host
27
+ self.port = config.port
27
28
  self.user = config.user
28
29
  self.password = config.password
29
30
  self.remote_path = config.remote_path
@@ -40,6 +41,7 @@ class FTPUploadService(BaseUploadService):
40
41
  self.close()
41
42
  try:
42
43
  self._client = ftplib.FTP(self.host, timeout=self.timeout)
44
+ self._client.connect(self.host, self.port, timeout=self.timeout)
43
45
  self._client.login(self.user, self.password)
44
46
  print(f"Connected to {self.host}")
45
47
  self._is_connect = True
@@ -55,7 +57,7 @@ class FTPUploadService(BaseUploadService):
55
57
  print("Connection closed.")
56
58
 
57
59
  def _parse(self, upload_data: FTPData) -> FTPParsedData:
58
- if upload_data.file_type == FTPFileType.CSV.value:
60
+ if upload_data.file_type == FTPFileType.CSV:
59
61
  parsed_data = CSVDataAdapter.parse_data(upload_data.data)
60
62
  else:
61
63
  raise NotImplementedError
@@ -0,0 +1,40 @@
1
+ import asyncio
2
+ import unittest
3
+
4
+ from solax_py_library.upload.api.service import upload
5
+ from solax_py_library.upload.types.client import UploadType, UploadData
6
+ from solax_py_library.upload.types.ftp import FTPFileType
7
+
8
+
9
+ class FTPTest(unittest.TestCase):
10
+ def test_ftp_upload(self):
11
+ ftp_config = {
12
+ "host": "10.1.31.181", # 测试host
13
+ "port": 21,
14
+ "user": "solax",
15
+ "password": "123456",
16
+ "remote_path": "/xixi",
17
+ }
18
+ asyncio.run(
19
+ upload(
20
+ upload_type=UploadType.FTP,
21
+ configuration=ftp_config,
22
+ upload_data=UploadData(
23
+ upload_type=UploadType.FTP,
24
+ data=dict(
25
+ file_type=FTPFileType.CSV,
26
+ file_name="new_file",
27
+ data=[
28
+ {
29
+ "EMS1000序列号": "XMG11A011L",
30
+ "EMS1000本地时间": "2025-02-11 15:39:10",
31
+ "EMS1000版本号": "V007.11.1",
32
+ "电站所在国家和地区": None,
33
+ "电站所在当前时区": None,
34
+ "电站系统类型": None,
35
+ }
36
+ ],
37
+ ),
38
+ ),
39
+ )
40
+ )
@@ -11,7 +11,7 @@ class FTPFileType(IntEnum):
11
11
  @classmethod
12
12
  def get_file_suffix(cls, value):
13
13
  return {
14
- FTPFileType.CSV.value: ".csv",
14
+ FTPFileType.CSV: ".csv",
15
15
  }.get(value)
16
16
 
17
17
 
@@ -26,6 +26,7 @@ class FTPData(BaseModel):
26
26
 
27
27
  class FTPServiceConfig(BaseModel):
28
28
  host: str
29
+ port: int
29
30
  user: Optional[str]
30
31
  password: Optional[str]
31
32
  remote_path: str
@@ -1,37 +0,0 @@
1
- import asyncio
2
- import unittest
3
-
4
- from solax_py_library.upload.api.service import upload
5
- from solax_py_library.upload.types.client import UploadType, UploadData
6
- from solax_py_library.upload.types.ftp import FTPFileType
7
-
8
-
9
- class FTPTest(unittest.TestCase):
10
- def test_ftp_upload(self):
11
- ftp_config = {
12
- "host": "10.1.31.181", # 测试host
13
- "user": "solax",
14
- "password": "sly402",
15
- "remote_path": "/xixi",
16
- }
17
- asyncio.run(upload(
18
- upload_type=UploadType.FTP,
19
- configuration=ftp_config,
20
- upload_data=UploadData(
21
- upload_type=UploadType.FTP,
22
- data=dict(
23
- file_type=FTPFileType.CSV,
24
- file_name="new_file",
25
- data=[
26
- {
27
- "EMS1000序列号": "XMG11A011L",
28
- "EMS1000本地时间": "2025-02-11 15:39:10",
29
- "EMS1000版本号": "V007.11.1",
30
- "电站所在国家和地区": None,
31
- "电站所在当前时区": None,
32
- "电站系统类型": None,
33
- }
34
- ],
35
- ),
36
- ),
37
- ))