solax-py-library 1.0.0.8__py3-none-any.whl → 1.0.0.10__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.
- solax_py_library/upload/core/upload_service/ftp.py +3 -1
- solax_py_library/upload/test/test_ftp.py +23 -20
- solax_py_library/upload/types/ftp.py +2 -1
- {solax_py_library-1.0.0.8.dist-info → solax_py_library-1.0.0.10.dist-info}/METADATA +2 -3
- {solax_py_library-1.0.0.8.dist-info → solax_py_library-1.0.0.10.dist-info}/RECORD +6 -6
- {solax_py_library-1.0.0.8.dist-info → solax_py_library-1.0.0.10.dist-info}/WHEEL +0 -0
@@ -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
|
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
|
@@ -10,28 +10,31 @@ class FTPTest(unittest.TestCase):
|
|
10
10
|
def test_ftp_upload(self):
|
11
11
|
ftp_config = {
|
12
12
|
"host": "10.1.31.181", # 测试host
|
13
|
+
"port": 21,
|
13
14
|
"user": "solax",
|
14
|
-
"password": "
|
15
|
+
"password": "123456",
|
15
16
|
"remote_path": "/xixi",
|
16
17
|
}
|
17
|
-
asyncio.run(
|
18
|
-
|
19
|
-
configuration=ftp_config,
|
20
|
-
upload_data=UploadData(
|
18
|
+
asyncio.run(
|
19
|
+
upload(
|
21
20
|
upload_type=UploadType.FTP,
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
data=
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
+
),
|
35
38
|
),
|
36
|
-
)
|
37
|
-
)
|
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
|
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,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: solax-py-library
|
3
|
-
Version: 1.0.0.
|
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
|
-
|
@@ -8,15 +8,15 @@ solax_py_library/upload/core/data_adapter/base.py,sha256=Va-SEe0eL3gobhNOnzHGkYB
|
|
8
8
|
solax_py_library/upload/core/data_adapter/csv.py,sha256=8nlnV_43mMAR3re50MQJymzT5HYpZOo7eSeMsEfnEVE,861
|
9
9
|
solax_py_library/upload/core/upload_service/__init__.py,sha256=uA-UeH31rDNxByeZwvPhNFHPV_-J8JyCev8geuc---k,269
|
10
10
|
solax_py_library/upload/core/upload_service/base.py,sha256=dxCBVtPxDhN7oRTjnwnjtc2XAF4hyIz9HsYCJePlggg,912
|
11
|
-
solax_py_library/upload/core/upload_service/ftp.py,sha256=
|
11
|
+
solax_py_library/upload/core/upload_service/ftp.py,sha256=2h7_Wwv_ozd24t5B4abCAs4VrWi7l1ByYJh8vvTiyzU,2794
|
12
12
|
solax_py_library/upload/errors/__init__.py,sha256=pVAcSOXvlsPJW3PjHLBOdbl7KvntiYmz7TP0XuRwZ_A,243
|
13
13
|
solax_py_library/upload/errors/base.py,sha256=T01ZrZHF25PWgCrOv76Vhg26hds3I1Yy8Kl2LZRKOxo,258
|
14
14
|
solax_py_library/upload/errors/upload_error.py,sha256=9pCZzR_y3-VkBWSs5w7mMHYFRJjzVosIcxi-5SO8N1U,409
|
15
15
|
solax_py_library/upload/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
solax_py_library/upload/test/test_ftp.py,sha256=
|
16
|
+
solax_py_library/upload/test/test_ftp.py,sha256=_d9JJ6KOaefTpbi9LO1YH84fUSsFlzdRdjedAlz36b8,1420
|
17
17
|
solax_py_library/upload/types/__init__.py,sha256=og9KBpYbcs36_S1izURj3vyHeuNOLJQrD9GpxK_JJaw,244
|
18
18
|
solax_py_library/upload/types/client.py,sha256=fG674_QEpOw3ibO171lcxJ0cz27yGR_sd3zgiyr4yuI,492
|
19
|
-
solax_py_library/upload/types/ftp.py,sha256=
|
20
|
-
solax_py_library-1.0.0.
|
21
|
-
solax_py_library-1.0.0.
|
22
|
-
solax_py_library-1.0.0.
|
19
|
+
solax_py_library/upload/types/ftp.py,sha256=9kCeLB0g5Je19v4ifz8YYEsGOhJL1lKBO2C6V2VBndc,679
|
20
|
+
solax_py_library-1.0.0.10.dist-info/METADATA,sha256=FR6Bc8lPlFYFS0AcERkefUdOLTRBbr79Cgq9LGVsSSc,1790
|
21
|
+
solax_py_library-1.0.0.10.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
22
|
+
solax_py_library-1.0.0.10.dist-info/RECORD,,
|
File without changes
|