You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As the imager will use os functions like os.listdir() and os.path.isdir(), it is best to create an abstraction layer of those functions (directory listing, checking if directory, etc).
That means that a general directory listing function should be used and have different implementation depending on what is listed (the running OS, a remote OS, SatoriImage object, etc).
Example:
[...]
context.listdir()
[...]
can have different meanings as of standard duck-typing as context can be anything (not only os module):
# Abstract ClassfromabcimportABC# In SatoriCoreclassSatoriAccessWrapper(ABC):
@abstractmethoddeflistdir(self): pass# MUST be implemented in subclassclassSatoriSMBWrapper(SatoriAccessWrapper):
def__init__(self, smbcon):
self.smbcon=smbcon# SMBConnection object
[...]
deflistdir(self, dir_path):
dir_list=self.smbcon.listPath('C$', '.') # accessing the real SMBConnection objectreturndir_list# Usage:context=SatoriSMBWrapper(smbcon)
context.listdir()
This way, what can be queried during an Imaging process will be easily controlled.
Additionally, this design will ensure extendability, as any new way to query a FileSystem will have to be wrapped through the SatoriAccessWrapper wrapper class. The Imager will just plug-n-play with those objects.
That's what Java calls interfaces.
The text was updated successfully, but these errors were encountered:
As the
imager
will useos
functions likeos.listdir()
andos.path.isdir()
, it is best to create an abstraction layer of those functions (directory listing, checking if directory, etc).That means that a general directory listing function should be used and have different implementation depending on what is listed (the running OS, a remote OS,
SatoriImage
object, etc).Example:
can have different meanings as of standard duck-typing as
context
can be anything (not onlyos
module):For running system OS with
os
module:For Paramiko's SFTP:
Extending for SatoriCore objects:
And wrappers can be created for objects that do not have the
listdir
interface (e.g:SMBHandler
ofpysmb
)Wrapping the
listPath()
ofpysmb
'sSMBConnection
:This way, what can be queried during an Imaging process will be easily controlled.
Additionally, this design will ensure extendability, as any new way to query a FileSystem will have to be wrapped through the
SatoriAccessWrapper
wrapper class. The Imager will just plug-n-play with those objects.That's what Java calls
interfaces
.The text was updated successfully, but these errors were encountered: