eric6/MicroPython/MicroPythonFileSystem.py

Thu, 18 Jul 2019 20:30:03 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 18 Jul 2019 20:30:03 +0200
branch
micropython
changeset 7067
3fc4082fc6ba
child 7070
3368ce0e7879
permissions
-rw-r--r--

Continued implementing the MicroPython support.

7067
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de>
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing some file system commands for MicroPython.
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from __future__ import unicode_literals
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtCore import QObject
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 class MicroPythonFileSystem(QObject):
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 Class implementing some file system commands for MicroPython.
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 Some FTP like commands are provided to perform operations on the file
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 system of a connected MicroPython device. Supported commands are:
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 <ul>
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 <li>ls: directory listing</li>
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 <li>lls: directory listing with meta data</li>
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 <li>cd: change directory</li>
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 <li>pwd: get the current directory</li>
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 <li>put: copy a file to the connected device</li>
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 <li>get: get a file from the connected device</li>
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 </ul>
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 def __init__(self, parent=None):
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Constructor
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param parent reference to the parent object
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @type QObject
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 super(MicroPythonFileSystem, self).__init__(parent)
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 def ls(self):
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 Public method to get a directory listing of the connected device.
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @return tuple containg the directory listing
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 @rtype tuple of str
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 # TODO: not implemented yet
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 def lls(self):
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 Public method to get a long directory listing of the connected device
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 including meta data.
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 @return tuple containg the the directory listing with tuple entries
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 containing the name, size, time and mode
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @rtype tuple of str
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 # TODO: not implemented yet
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 def cd(self, path):
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 Public method to change the current directory on the connected device.
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 @param path directory to change to
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @type str
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 # TODO: not implemented yet
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 def pwd(self):
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 Public method to get the current directory of the connected device.
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 @return current directory
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 @rtype str
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 # TODO: not implemented yet
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 def put(self, hostFileName, deviceFileName):
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 Public method to copy a local file to the connected device.
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @param hostFileName name of the file to be copied
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 @type str
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @param deviceFileName name of the file to copy to
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @type str
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 @return flag indicating success
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 @rtype bool
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 # TODO: not implemented yet
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 def get(self, deviceFileName, hostFileName):
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 Public method to copy a file from the connected device.
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 @param deviceFileName name of the file to copy
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 @type str
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 @param hostFileName name of the file to copy to
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 @type str
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 @return flag indicating success
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 @rtype bool
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
3fc4082fc6ba Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 # TODO: not implemented yet

eric ide

mercurial