Wed, 01 Jan 2020 11:57:23 +0100
Updated copyright for 2020.
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
7360
9190402e4505
Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7259
diff
changeset
|
3 | # Copyright (c) 2012 - 2020 Detlev Offenbach <detlev@die-offenbachs.de> |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing some FTP related utilities. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2302
diff
changeset
|
10 | |
2050
585f6646bf50
Changed the FtpReply to support proxy access and to not show user and password in the URL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2047
diff
changeset
|
11 | import os |
585f6646bf50
Changed the FtpReply to support proxy access and to not show user and password in the URL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2047
diff
changeset
|
12 | |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3591
diff
changeset
|
13 | from PyQt5.QtCore import QObject, QDate, QDateTime, QTime |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
14 | |
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
15 | from E5Network.E5UrlInfo import E5UrlInfo |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | class FtpDirLineParserError(Exception): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | Exception class raised, if a parser issue was detected. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | """ |
2965
d133c7edd88a
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
22 | pass |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | class FtpDirLineParser(QObject): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | Class to parse lines returned by a FTP LIST command. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | MonthnamesNumbers = { |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | "jan": 1, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | "feb": 2, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | "mar": 3, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | "apr": 4, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | "may": 5, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | "jun": 6, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | "jul": 7, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | "aug": 8, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | "sep": 9, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | "oct": 10, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | "nov": 11, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | "dec": 12, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | } |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | def __init__(self, parent=None): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | Constructor |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | @param parent reference to the parent object (QObject) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | """ |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2302
diff
changeset
|
50 | super(FtpDirLineParser, self).__init__(parent) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | self.__parseLine = self.__parseUnixLine |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | self.__modeSwitchAllowed = True |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | def __ignoreLine(self, line): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | Private method to check, if the line should be ignored. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | @param line to check (string) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | @return flag indicating to ignore the line (boolean) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | """ |
7259
7c017076c12e
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
62 | return ( |
7c017076c12e
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
63 | line.strip() == "" or |
3039
8dd0165d805d
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
64 | line.strip().lower().startswith("total ") |
7259
7c017076c12e
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
65 | ) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | def __parseUnixMode(self, modeString, urlInfo): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | Private method to parse a Unix mode string modifying the |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | given URL info object. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | @param modeString mode string to be parsed (string) |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
73 | @param urlInfo reference to the URL info object (E5UrlInfo) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | @exception FtpDirLineParserError Raised if the mode cannot be parsed. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | if len(modeString) != 10: |
2997
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
77 | raise FtpDirLineParserError( |
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
78 | "invalid mode string '{0}'".format(modeString)) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | modeString = modeString.lower() |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | permission = 0 |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | if modeString[1] != '-': |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
84 | permission |= E5UrlInfo.ReadOwner |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | if modeString[2] != '-': |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
86 | permission |= E5UrlInfo.WriteOwner |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | if modeString[3] != '-': |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
88 | permission |= E5UrlInfo.ExeOwner |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | if modeString[4] != '-': |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
90 | permission |= E5UrlInfo.ReadGroup |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | if modeString[5] != '-': |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
92 | permission |= E5UrlInfo.WriteGroup |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | if modeString[6] != '-': |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
94 | permission |= E5UrlInfo.ExeGroup |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | if modeString[7] != '-': |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
96 | permission |= E5UrlInfo.ReadOther |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | if modeString[8] != '-': |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
98 | permission |= E5UrlInfo.WriteOther |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | if modeString[9] != '-': |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
100 | permission |= E5UrlInfo.ExeOther |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | urlInfo.setPermissions(permission) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | if modeString[0] == "d": |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | urlInfo.setDir(True) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | urlInfo.setFile(False) |
2050
585f6646bf50
Changed the FtpReply to support proxy access and to not show user and password in the URL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2047
diff
changeset
|
106 | urlInfo.setSymLink(False) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | elif modeString[0] == "l": |
2052
b89c21c96127
Fixed an error in the FTP utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2051
diff
changeset
|
108 | urlInfo.setDir(True) |
2050
585f6646bf50
Changed the FtpReply to support proxy access and to not show user and password in the URL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2047
diff
changeset
|
109 | urlInfo.setFile(False) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | urlInfo.setSymLink(True) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | elif modeString[0] == "-": |
2052
b89c21c96127
Fixed an error in the FTP utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2051
diff
changeset
|
112 | urlInfo.setDir(False) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | urlInfo.setFile(True) |
2050
585f6646bf50
Changed the FtpReply to support proxy access and to not show user and password in the URL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2047
diff
changeset
|
114 | urlInfo.setSymLink(False) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | def __parseUnixTime(self, monthAbbreviation, day, yearOrTime, urlInfo): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | Private method to parse a Unix date and time indication modifying |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | the given URL info object. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | Date time strings in Unix-style directory listings typically |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | have one of these formats: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | <ul> |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | <li>"Nov 23 02:33" (month name, day of month, time)</li> |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | <li>"May 26 2005" (month name, day of month, year)</li> |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | </ul> |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | @param monthAbbreviation abbreviation of the month name (string) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | @param day day of the month (string) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | @param yearOrTime string giving the year or a time (string) |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
132 | @param urlInfo reference to the URL info object (E5UrlInfo) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | @exception FtpDirLineParserError Raised if the month abbreviation is |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | not recognized. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | try: |
2997
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
137 | month = FtpDirLineParser.MonthnamesNumbers[ |
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
138 | monthAbbreviation.lower()] |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | except KeyError: |
2997
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
140 | raise FtpDirLineParserError( |
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
141 | "illegal month abbreviation '{0}'".format( |
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
142 | monthAbbreviation)) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | day = int(day) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | if ':' in yearOrTime: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | year = QDate.currentDate().year() |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | hour, minute = yearOrTime.split(':') |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | hour = int(hour) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | minute = int(minute) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | else: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | year = int(yearOrTime) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | hour = 0 |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | minute = 0 |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | lastModified = QDateTime(QDate(year, month, day), QTime(hour, minute)) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | urlInfo.setLastModified(lastModified) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | def __splitUnixLine(self, line): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | """ |
2965
d133c7edd88a
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
159 | Private method to split a line of a Unix like directory listing. |
d133c7edd88a
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
160 | |
d133c7edd88a
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
161 | It splits the line into meta data, number of links, user, group, size, |
d133c7edd88a
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
162 | month, day, year or time and name. |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | |
2965
d133c7edd88a
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
164 | @param line directory line to split (string) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | @return tuple of nine strings giving the meta data, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | number of links, user, group, size, month, day, year or time |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | and name |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | @exception FtpDirLineParserError Raised if the line is not of a |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | recognized Unix format. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | # This method encapsulates the recognition of an unusual |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | # Unix format variant. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | lineParts = line.split() |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | fieldCountWithoutUserID = 8 |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | fieldCountWithUserID = fieldCountWithoutUserID + 1 |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | if len(lineParts) < fieldCountWithoutUserID: |
2997
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
177 | raise FtpDirLineParserError( |
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
178 | "line '{0}' cannot be parsed".format(line)) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | # If we have a valid format (either with or without user id field), |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | # the field with index 5 is either the month abbreviation or a day. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | try: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | int(lineParts[5]) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | except ValueError: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | # Month abbreviation, "invalid literal for int" |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | lineParts = line.split(None, fieldCountWithUserID - 1) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | else: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | # Day |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | lineParts = line.split(None, fieldCountWithoutUserID - 1) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | userFieldIndex = 2 |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | lineParts.insert(userFieldIndex, "") |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | return lineParts |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | def __parseUnixLine(self, line): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | Private method to parse a Unix style directory listing line. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | @param line directory line to be parsed (string) |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
200 | @return URL info object containing the valid data (E5UrlInfo) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | """ |
7259
7c017076c12e
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
202 | modeString, nlink, user, group, size, month, day, yearOrTime, name = ( |
7c017076c12e
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
203 | self.__splitUnixLine(line) |
7c017076c12e
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
204 | ) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | |
2051
644d5a2585a8
Changed the FTP directory parser to omit the '.' and '..' directories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2050
diff
changeset
|
206 | if name in [".", ".."]: |
644d5a2585a8
Changed the FTP directory parser to omit the '.' and '..' directories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2050
diff
changeset
|
207 | return None |
644d5a2585a8
Changed the FTP directory parser to omit the '.' and '..' directories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2050
diff
changeset
|
208 | |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
209 | urlInfo = E5UrlInfo() |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | self.__parseUnixMode(modeString, urlInfo) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | self.__parseUnixTime(month, day, yearOrTime, urlInfo) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | urlInfo.setOwner(user) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | urlInfo.setGroup(group) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | urlInfo.setSize(int(size)) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | name = name.strip() |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | i = name.find(" -> ") |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | if i >= 0: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | name = name[:i] |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | urlInfo.setName(name) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | return urlInfo |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | def __parseWindowsTime(self, date, time, urlInfo): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | Private method to parse a Windows date and time indication modifying |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | the given URL info object. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | Date time strings in Windows-style directory listings typically |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | have the format "10-23-12 03:25PM" (month-day_of_month-two_digit_year, |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | hour:minute, am/pm). |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | @param date date string (string) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | @param time time string (string) |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
234 | @param urlInfo reference to the URL info object (E5UrlInfo) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | @exception FtpDirLineParserError Raised if either of the strings is not |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | recognized. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | try: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | month, day, year = [int(part) for part in date.split('-')] |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | if year >= 70: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | year = 1900 + year |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | else: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | year = 2000 + year |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | except (ValueError, IndexError): |
2997
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
245 | raise FtpDirLineParserError( |
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
246 | "illegal date string '{0}'".format(month)) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | try: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | hour, minute, am_pm = time[0:2], time[3:5], time[5] |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | hour = int(hour) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
250 | minute = int(minute) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | except (ValueError, IndexError): |
2997
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
252 | raise FtpDirLineParserError( |
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
253 | "illegal time string '{0}'".format(month)) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | if hour == 12 and am_pm == 'A': |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
255 | hour = 0 |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | if hour != 12 and am_pm == 'P': |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
257 | hour = hour + 12 |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | lastModified = QDateTime(QDate(year, month, day), QTime(hour, minute)) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | urlInfo.setLastModified(lastModified) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | def __parseWindowsLine(self, line): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | Private method to parse a Windows style directory listing line. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | @param line directory line to be parsed (string) |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
267 | @return URL info object containing the valid data (E5UrlInfo) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | @exception FtpDirLineParserError Raised if the line is not of a |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
269 | recognized Windows format. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | try: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
272 | date, time, dirOrSize, name = line.split(None, 3) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | except ValueError: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | # "unpack list of wrong size" |
2997
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
275 | raise FtpDirLineParserError( |
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
276 | "line '{0}' cannot be parsed".format(line)) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | |
2051
644d5a2585a8
Changed the FTP directory parser to omit the '.' and '..' directories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2050
diff
changeset
|
278 | if name in [".", ".."]: |
644d5a2585a8
Changed the FTP directory parser to omit the '.' and '..' directories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2050
diff
changeset
|
279 | return None |
644d5a2585a8
Changed the FTP directory parser to omit the '.' and '..' directories.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2050
diff
changeset
|
280 | |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
281 | urlInfo = E5UrlInfo() |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | self.__parseWindowsTime(date, time, urlInfo) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
283 | if dirOrSize.lower() == "<dir>": |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
284 | urlInfo.setDir(True) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
285 | urlInfo.setFile(False) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | else: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | urlInfo.setDir(False) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | urlInfo.setFile(True) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | try: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
290 | urlInfo.setSize(int(dirOrSize)) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
291 | except ValueError: |
2997
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
292 | raise FtpDirLineParserError( |
7f0ef975da9e
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
293 | "illegal size '{0}'".format(dirOrSize)) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
294 | urlInfo.setName(name) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
295 | |
2050
585f6646bf50
Changed the FtpReply to support proxy access and to not show user and password in the URL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2047
diff
changeset
|
296 | ext = os.path.splitext(name.lower())[1] |
585f6646bf50
Changed the FtpReply to support proxy access and to not show user and password in the URL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2047
diff
changeset
|
297 | urlInfo.setSymLink(ext == ".lnk") |
585f6646bf50
Changed the FtpReply to support proxy access and to not show user and password in the URL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2047
diff
changeset
|
298 | |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2997
diff
changeset
|
299 | permissions = (E5UrlInfo.ReadOwner | E5UrlInfo.WriteOwner | |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2997
diff
changeset
|
300 | E5UrlInfo.ReadGroup | E5UrlInfo.WriteGroup | |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2997
diff
changeset
|
301 | E5UrlInfo.ReadOther | E5UrlInfo.WriteOther) |
2050
585f6646bf50
Changed the FtpReply to support proxy access and to not show user and password in the URL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2047
diff
changeset
|
302 | if ext in [".exe", ".com", ".bat", ".cmd"]: |
7259
7c017076c12e
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
303 | permissions |= ( |
7c017076c12e
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
304 | E5UrlInfo.ExeOwner | E5UrlInfo.ExeGroup | E5UrlInfo.ExeOther |
7c017076c12e
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
305 | ) |
2050
585f6646bf50
Changed the FtpReply to support proxy access and to not show user and password in the URL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2047
diff
changeset
|
306 | urlInfo.setPermissions(permissions) |
585f6646bf50
Changed the FtpReply to support proxy access and to not show user and password in the URL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2047
diff
changeset
|
307 | |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | return urlInfo |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
309 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
310 | def parseLine(self, line): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
311 | """ |
3591
2f2a4a76dd22
Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
312 | Public method to parse a directory listing line. |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
313 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
314 | This implementation support Unix and Windows style directory |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | listings. It tries Unix style first and if that fails switches |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
316 | to Windows style. If that fails as well, an exception is raised. |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
317 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
318 | @param line directory line to be parsed (string) |
2077
68a34718a0ce
Made the first set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2052
diff
changeset
|
319 | @return URL info object containing the valid data (E5UrlInfo) |
2047
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
320 | """ |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
321 | if self.__ignoreLine(line): |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
322 | return None |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
323 | |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | try: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
325 | return self.__parseLine(line) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
326 | except FtpDirLineParserError: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
327 | if self.__modeSwitchAllowed: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
328 | self.__parseLine = self.__parseWindowsLine |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
329 | self.__modeSwitchAllowed = False |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
330 | return self.__parseLine(line) |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
331 | else: |
739aa1717df5
Extended the new FtpReply class to handle various directory listing styles and to ask for a username and password, if the FTP login fails with an error code of 530.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
332 | raise |