Python stat.S_ISDOOR Examples
The following are 2
code examples of stat.S_ISDOOR().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
stat
, or try the search function
.
Example #1
Source File: plugin.py From phpsploit with GNU General Public License v3.0 | 6 votes |
def mode_filetype(mode): mode = stat.S_IFMT(mode) dic = { stat.S_ISFIFO: "fifo file", stat.S_ISCHR: "character device", stat.S_ISDIR: "directory", stat.S_ISBLK: "block device", stat.S_ISREG: "regular file", stat.S_ISLNK: "symbolic link", stat.S_ISSOCK: "socket", stat.S_ISDOOR: "door", } for test_func, name in dic.items(): if test_func(mode): return name return "???"
Example #2
Source File: __init__.py From platypush with MIT License | 4 votes |
def ls(self, path: str = '.', attrs: bool = False, keep_alive: bool = False, **kwargs) \ -> Union[List[str], Dict[str, Any]]: """ Return the list of files in a path on a remote server. :param path: Remote path (default: current directory). :param keep_alive: Keep the connection active after running the command (default: False). :param attrs: Set to True if you want to get the full information of each file (default: False). :param kwargs: Arguments for :meth:`platypush.plugins.ssh.SshPlugin.connect`. :return: A list of filenames if ``attrs=False``, otherwise a dictionary ``filename -> {attributes`` if ``attrs=True``. """ client = self._connect(**kwargs) sftp = client.open_sftp() def get_file_type(st_mode: int) -> str: if S_ISDIR(st_mode): return 'directory' elif S_ISBLK(st_mode): return 'block' elif S_ISCHR(st_mode): return 'device' elif S_ISDOOR(st_mode): return 'door' elif S_ISREG(st_mode): return 'file' elif S_ISLNK(st_mode): return 'link' elif S_ISFIFO(st_mode): return 'fifo' elif S_ISSOCK(st_mode): return 'sock' else: return 'unknown' try: if attrs: return { f.filename: { 'filename': f.filename, 'longname': f.longname, 'attributes': f.attr, 'type': get_file_type(f.st_mode), 'access_time': datetime.datetime.fromtimestamp(f.st_atime), 'modify_time': datetime.datetime.fromtimestamp(f.st_mtime), 'uid': f.st_uid, 'gid': f.st_gid, 'size': f.st_size, } for f in sftp.listdir_attr(path) } else: return sftp.listdir(path) finally: if not keep_alive: host, port, user = self._get_host_port_user(**kwargs) self.disconnect(host=host, port=port, user=user)