Python stat.S_IXOTH Examples
The following are 30
code examples of stat.S_IXOTH().
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: makebin.py From pydarkstar with MIT License | 7 votes |
def chmod(path): os.chmod(path, # user stat.S_IRUSR | # read stat.S_IWUSR | # write stat.S_IXUSR | # execute # group stat.S_IRGRP | # read stat.S_IWGRP | # write stat.S_IXGRP | # execute # other stat.S_IROTH | # read # stat.S_IWOTH | # write stat.S_IXOTH # execute )
Example #2
Source File: test_import.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_execute_bit_not_copied(self): # Issue 6070: under posix .pyc files got their execute bit set if # the .py file had the execute bit set, but they aren't executable. oldmask = os.umask(022) sys.path.insert(0, os.curdir) try: fname = TESTFN + os.extsep + "py" f = open(fname, 'w').close() os.chmod(fname, (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)) __import__(TESTFN) fn = fname + 'c' if not os.path.exists(fn): fn = fname + 'o' if not os.path.exists(fn): self.fail("__import__ did not result in creation of " "either a .pyc or .pyo file") s = os.stat(fn) self.assertEqual(stat.S_IMODE(s.st_mode), stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) finally: os.umask(oldmask) remove_files(TESTFN) unload(TESTFN) del sys.path[0]
Example #3
Source File: test_import.py From oss-ftp with MIT License | 6 votes |
def test_execute_bit_not_copied(self): # Issue 6070: under posix .pyc files got their execute bit set if # the .py file had the execute bit set, but they aren't executable. oldmask = os.umask(022) sys.path.insert(0, os.curdir) try: fname = TESTFN + os.extsep + "py" f = open(fname, 'w').close() os.chmod(fname, (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)) __import__(TESTFN) fn = fname + 'c' if not os.path.exists(fn): fn = fname + 'o' if not os.path.exists(fn): self.fail("__import__ did not result in creation of " "either a .pyc or .pyo file") s = os.stat(fn) self.assertEqual(stat.S_IMODE(s.st_mode), stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) finally: os.umask(oldmask) remove_files(TESTFN) unload(TESTFN) del sys.path[0]
Example #4
Source File: connection_getAllDomainStats.py From libvirt-test-API with GNU General Public License v2.0 | 6 votes |
def prepare_shutoff_daemon(logger): if not os.path.exists(hooks_dir): os.makedirs(hooks_dir) if os.path.exists(hooks_file): os.remove(hooks_file) with open(hooks_file, 'w') as f: f.write(hooks_str) if not os.access(hooks_file, os.X_OK): st = os.stat(hooks_file) os.chmod(hooks_file, st.st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH) cmd = "service libvirtd restart" ret, out = utils.exec_cmd(cmd, shell=True) if ret: logger.error("Restart libvirtd failed: %s" % out) return 1 return 0
Example #5
Source File: test_import.py From BinderFilter with MIT License | 6 votes |
def test_execute_bit_not_copied(self): # Issue 6070: under posix .pyc files got their execute bit set if # the .py file had the execute bit set, but they aren't executable. oldmask = os.umask(022) sys.path.insert(0, os.curdir) try: fname = TESTFN + os.extsep + "py" f = open(fname, 'w').close() os.chmod(fname, (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)) __import__(TESTFN) fn = fname + 'c' if not os.path.exists(fn): fn = fname + 'o' if not os.path.exists(fn): self.fail("__import__ did not result in creation of " "either a .pyc or .pyo file") s = os.stat(fn) self.assertEqual(stat.S_IMODE(s.st_mode), stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) finally: os.umask(oldmask) remove_files(TESTFN) unload(TESTFN) del sys.path[0]
Example #6
Source File: base.py From libnacl with Apache License 2.0 | 6 votes |
def save(self, path, serial='json'): ''' Safely save keys with perms of 0400 ''' pre = self.for_json() if serial == 'msgpack': import msgpack packaged = msgpack.dumps(pre) elif serial == 'json': import json packaged = json.dumps(pre) perm_other = stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH perm_group = stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP cumask = os.umask(perm_other | perm_group) with open(path, 'w+') as fp_: fp_.write(packaged) os.umask(cumask)
Example #7
Source File: device_utils_test.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
def testStatDirectory_filePermissions(self): should_have = ( ('some_file', stat.S_IWUSR), # Owner can write. ('tmp', stat.S_IXOTH), # Others can execute. ('tmp', stat.S_ISVTX), # Has sticky bit. ('my_cmd', stat.S_ISGID), # Has set-group-ID bit. ('silly', stat.S_ISUID), # Has set UID bit. ) should_not_have = ( ('some_file', stat.S_IWOTH), # Others can't write. ('block_dev', stat.S_IRGRP), # Group can't read. ('silly', stat.S_IXUSR), # Owner can't execute. ) entries = self.getStatEntries() for filename, bit in should_have: self.assertTrue(entries[filename]['st_mode'] & bit) for filename, bit in should_not_have: self.assertFalse(entries[filename]['st_mode'] & bit)
Example #8
Source File: device_utils_test.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
def testStatDirectory_filePermissions(self): should_have = ( ('some_file', stat.S_IWUSR), # Owner can write. ('tmp', stat.S_IXOTH), # Others can execute. ('tmp', stat.S_ISVTX), # Has sticky bit. ('my_cmd', stat.S_ISGID), # Has set-group-ID bit. ('silly', stat.S_ISUID), # Has set UID bit. ) should_not_have = ( ('some_file', stat.S_IWOTH), # Others can't write. ('block_dev', stat.S_IRGRP), # Group can't read. ('silly', stat.S_IXUSR), # Owner can't execute. ) entries = self.getStatEntries() for filename, bit in should_have: self.assertTrue(entries[filename]['st_mode'] & bit) for filename, bit in should_not_have: self.assertFalse(entries[filename]['st_mode'] & bit)
Example #9
Source File: data_dir.py From avocado-vt with GNU General Public License v2.0 | 6 votes |
def get_tmp_dir(public=True): """ Get the most appropriate tmp dir location. :param public: If public for all users' access """ persistent_dir = settings.get_value('vt.common', 'tmp_dir', default="") if persistent_dir != "": return persistent_dir tmp_dir = None # apparmor deny /tmp/* /var/tmp/* and cause failure across tests # it is better to handle here if distro.detect().name == 'Ubuntu': tmp_dir = "/var/lib/libvirt/images" if not utils_path.usable_rw_dir(tmp_dir): logging.warning("Unable to write in '/var/lib/libvirt/images' " "on Ubuntu, apparmor might complain...") tmp_dir = None tmp_dir = data_dir.get_tmp_dir(basedir=tmp_dir) if public: tmp_dir_st = os.stat(tmp_dir) os.chmod(tmp_dir, tmp_dir_st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH | stat.S_IRGRP | stat.S_IROTH) return tmp_dir
Example #10
Source File: utils_disk.py From avocado-vt with GNU General Public License v2.0 | 6 votes |
def close(self): error_context.context( "Creating unattended install CD image %s" % self.path) if os.path.exists(os.path.join(self.mount, 'isolinux')): # bootable cdrom f = open(os.path.join(self.mount, 'isolinux', 'isolinux.cfg'), 'w') f.write('default /isolinux/vmlinuz append initrd=/isolinux/' 'initrd.img %s\n' % self.extra_params) f.close() boot = '-b isolinux/isolinux.bin' else: # Not a bootable CDROM, using -kernel instead (eg.: arm64) boot = '' m_cmd = ('mkisofs -o %s %s -c isolinux/boot.cat -no-emul-boot ' '-boot-load-size 4 -boot-info-table -f -R -J -V -T %s' % (self.path, boot, self.mount)) process.run(m_cmd) os.chmod(self.path, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH) cleanup(self.mount) cleanup(self.source_cdrom) logging.debug("unattended install CD image %s successfully created", self.path)
Example #11
Source File: device_utils_test.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
def testStatDirectory_filePermissions(self): should_have = ( ('some_file', stat.S_IWUSR), # Owner can write. ('tmp', stat.S_IXOTH), # Others can execute. ('tmp', stat.S_ISVTX), # Has sticky bit. ('my_cmd', stat.S_ISGID), # Has set-group-ID bit. ('silly', stat.S_ISUID), # Has set UID bit. ) should_not_have = ( ('some_file', stat.S_IWOTH), # Others can't write. ('block_dev', stat.S_IRGRP), # Group can't read. ('silly', stat.S_IXUSR), # Owner can't execute. ) entries = self.getStatEntries() for filename, bit in should_have: self.assertTrue(entries[filename]['st_mode'] & bit) for filename, bit in should_not_have: self.assertFalse(entries[filename]['st_mode'] & bit)
Example #12
Source File: actions.py From st2 with Apache License 2.0 | 6 votes |
def _write_data_file(self, pack_ref, file_path, content): """ Write data file on disk. """ # Throw if pack directory doesn't exist pack_base_path = get_pack_base_path(pack_name=pack_ref) if not os.path.isdir(pack_base_path): raise ValueError('Directory for pack "%s" doesn\'t exist' % (pack_ref)) # Create pack sub-directory tree if it doesn't exist directory = os.path.dirname(file_path) if not os.path.isdir(directory): # NOTE: We apply same permission bits as we do on pack install. If we don't do that, # st2api won't be able to write to pack sub-directory mode = stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH os.makedirs(directory, mode) with open(file_path, 'w') as fp: fp.write(content)
Example #13
Source File: setup-py2exe.py From opsbro with MIT License | 6 votes |
def _chmodplusx(d): if not os.path.exists(d): return if os.path.isdir(d): for item in os.listdir(d): p = os.path.join(d, item) if os.path.isdir(p): _chmodplusx(p) else: st = os.stat(p) os.chmod(p, st.st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH) else: st = os.stat(d) os.chmod(d, st.st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH) ################################## Hook the ugly python setup() call that can output gcc warnings. # NOTE: yes, there is os.dup and file descriptor things. Deal with it (r). # Keep a trace of the old stdout, because setup() is just toooooooooo verbose when succeed
Example #14
Source File: taskScript.py From script.service.kodi.callbacks with GNU General Public License v3.0 | 6 votes |
def validate(taskKwargs, xlog=KodiLogger.log): tmpl = process_cmdline(taskKwargs['scriptfile']) found = False for tmp in tmpl: tmp = xbmc.translatePath(tmp) if xbmcvfs.exists(tmp) or os.path.exists(tmp) and found is False: try: mode = os.stat(tmp).st_mode mode |= stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH os.chmod(tmp, mode) except OSError: if sysplat.startswith('win') is False: xlog(msg=_('Failed to set execute bit on script: %s') % tmp) finally: found = True return True
Example #15
Source File: fs.py From s3ql with GNU General Public License v3.0 | 6 votes |
def symlink(self, id_p, name, target, ctx): log.debug('started with %d, %r, %r', id_p, name, target) if self.failsafe: raise FUSEError(errno.EPERM) mode = (stat.S_IFLNK | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH) # Unix semantics require the size of a symlink to be the length # of its target. Therefore, we create symlink directory entries # with this size. If the kernel ever learns to open and read # symlinks directly, it will read the corresponding number of \0 # bytes. inode = self._create(id_p, name, mode, ctx, size=len(target)) self.db.execute('INSERT INTO symlink_targets (inode, target) VALUES(?,?)', (inode.id, target)) self.open_inodes[inode.id] += 1 return inode.entry_attributes()
Example #16
Source File: mkfs.py From s3ql with GNU General Public License v3.0 | 6 votes |
def init_tables(conn): # Insert root directory now_ns = time_ns() conn.execute("INSERT INTO inodes (id,mode,uid,gid,mtime_ns,atime_ns,ctime_ns,refcount) " "VALUES (?,?,?,?,?,?,?,?)", (ROOT_INODE, stat.S_IFDIR | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH, os.getuid(), os.getgid(), now_ns, now_ns, now_ns, 1)) # Insert control inode, the actual values don't matter that much conn.execute("INSERT INTO inodes (id,mode,uid,gid,mtime_ns,atime_ns,ctime_ns,refcount) " "VALUES (?,?,?,?,?,?,?,?)", (CTRL_INODE, stat.S_IFREG | stat.S_IRUSR | stat.S_IWUSR, 0, 0, now_ns, now_ns, now_ns, 42)) # Insert lost+found directory inode = conn.rowid("INSERT INTO inodes (mode,uid,gid,mtime_ns,atime_ns,ctime_ns,refcount) " "VALUES (?,?,?,?,?,?,?)", (stat.S_IFDIR | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR, os.getuid(), os.getgid(), now_ns, now_ns, now_ns, 1)) name_id = conn.rowid('INSERT INTO names (name, refcount) VALUES(?,?)', (b'lost+found', 1)) conn.execute("INSERT INTO contents (name_id, inode, parent_inode) VALUES(?,?,?)", (name_id, inode, ROOT_INODE))
Example #17
Source File: setup.py From opsbro with MIT License | 6 votes |
def _chmodplusx(d): if not os.path.exists(d): return if os.path.isdir(d): for item in os.listdir(d): p = os.path.join(d, item) if os.path.isdir(p): _chmodplusx(p) else: st = os.stat(p) os.chmod(p, st.st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH) else: st = os.stat(d) os.chmod(d, st.st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH) ################################## Hook the ugly python setup() call that can output gcc warnings. # NOTE: yes, there is os.dup and file descriptor things. Deal with it (r). # Keep a trace of the old stdout, because setup() is just toooooooooo verbose when succeed
Example #18
Source File: lib.py From marsnake with GNU General Public License v3.0 | 6 votes |
def special_to_letter(mode): l = '' ALL_R = (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) ALL_W = (stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH) if mode & stat.S_ISGID: l += 'G' if mode & stat.S_ISUID: l += 'U' if mode & stat.S_ISVTX: l += 'T' if mode & (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH): l += 'E' if ( mode & ALL_R ) == ALL_R: l += 'R' if ( mode & ALL_W ) == ALL_W: l += 'W' return l
Example #19
Source File: directory.py From king-phisher-plugins with BSD 3-Clause "New" or "Revised" License | 6 votes |
def render_python_value(value): if not isinstance(value, int): return if value & stat.S_IFDIR: perm = 'd' else: perm = '-' perm += 'r' if value & stat.S_IRUSR else '-' perm += 'w' if value & stat.S_IWUSR else '-' if value & stat.S_ISUID: perm += 's' if value & stat.S_IXUSR else 'S' else: perm += 'x' if value & stat.S_IXUSR else '-' perm += 'r' if value & stat.S_IRGRP else '-' perm += 'w' if value & stat.S_IWGRP else '-' if value & stat.S_ISGID: perm += 's' if value & stat.S_IXGRP else 'S' else: perm += 'x' if value & stat.S_IXGRP else '-' perm += 'r' if value & stat.S_IROTH else '-' perm += 'w' if value & stat.S_IWOTH else '-' perm += 'x' if value & stat.S_IXOTH else '-' return perm
Example #20
Source File: test_import.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_execute_bit_not_copied(self): # Issue 6070: under posix .pyc files got their execute bit set if # the .py file had the execute bit set, but they aren't executable. oldmask = os.umask(022) sys.path.insert(0, os.curdir) try: fname = TESTFN + os.extsep + "py" f = open(fname, 'w').close() os.chmod(fname, (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)) __import__(TESTFN) fn = fname + 'c' if not os.path.exists(fn): fn = fname + 'o' if not os.path.exists(fn): self.fail("__import__ did not result in creation of " "either a .pyc or .pyo file") s = os.stat(fn) self.assertEqual(stat.S_IMODE(s.st_mode), stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) finally: os.umask(oldmask) remove_files(TESTFN) unload(TESTFN) del sys.path[0]
Example #21
Source File: examples.py From simnibs with GNU General Public License v3.0 | 6 votes |
def replace_gmsh(): fn_gmsh = path2bin('gmsh') fn_gmsh_tmp = path2bin('gmsh_tmp') # move shutil.move(fn_gmsh, fn_gmsh_tmp) # replace if sys.platform == 'win32': fn_script = fn_gmsh[:4] + '.cmd' with open(fn_script, 'w') as f: f.write('echo "GMSH"') else: with open(fn_gmsh, 'w') as f: f.write('#! /bin/bash -e\n') f.write(f'"echo" "$@"') os.chmod( fn_gmsh, os.stat(fn_gmsh).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH ) yield shutil.move(fn_gmsh_tmp, fn_gmsh)
Example #22
Source File: test_organice_setup.py From django-organice with Apache License 2.0 | 6 votes |
def test_01_create_project(self, tmpdir, project_name, cmd_args, setup): """ - does setup command execute and finish? - does manage script exist, and is it executable? """ mode0755 = oct(S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)[-3:] manage_script = 'manage.py' tmpdir.chdir() exit_code = call(['organice-setup', '--set', 'develop', 'TEST_SETTING_01', "'test value'", '--verbosity=0'] + cmd_args + [project_name]) assert exit_code == 0 assert isfile(manage_script) file_mode = oct(stat(manage_script).st_mode)[-3:] assert file_mode == mode0755 with open(manage_script) as script: content = script.read() assert 'execute_from_command_line' in content assert ('multi' in cmd_args) != ('DJANGO_SETTINGS_MODULE' in content)
Example #23
Source File: cdrom.py From nitro with GNU General Public License v3.0 | 5 votes |
def __init__(self): # create cdrom dir self.cdrom_dir_tmp = TemporaryDirectory() self.tmp_dir = TemporaryDirectory() self.cdrom_iso_tmp = None # give qemu permission to execute and read in this directory os.chmod(self.tmp_dir.name, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH) self.cdrom_dir = self.cdrom_dir_tmp.name self.cdrom_iso_tmp = None
Example #24
Source File: kodipathtools.py From script.service.kodi.callbacks with GNU General Public License v3.0 | 5 votes |
def setPathExecute(path): path = translatepath(path) try: os.chmod(path, os.stat(path).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) except OSError: pass
Example #25
Source File: util.py From pre-commit with MIT License | 5 votes |
def make_executable(filename: str) -> None: original_mode = os.stat(filename).st_mode new_mode = original_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH os.chmod(filename, new_mode)
Example #26
Source File: builder.py From promenade with Apache License 2.0 | 5 votes |
def _write_script(output_dir, name, script): path = os.path.join(output_dir, name) with open(path, 'w') as f: f.write(script) os.chmod( path, os.stat(path).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
Example #27
Source File: template.py From zentral with Apache License 2.0 | 5 votes |
def install_scepclient(): url = "https://github.com/micromdm/scep/releases/download/v1.0.0/scep.zip" # follow redirects while True: resp = urllib.request.urlopen(url) if resp.geturl() == url: break url = resp.geturl() # save zip tfh, tfn = tempfile.mkstemp(suffix=".zip") tf = os.fdopen(tfh, "wb") while True: chunk = resp.read(64 * 2**10) if not chunk: break tf.write(chunk) tf.close() with zipfile.ZipFile(tfn) as zf: isbf = zf.open('build/scepclient-linux-amd64', 'r') osbf = open(SCEPCLIENT, "wb") while True: chunk = isbf.read(64 * 2**10) if not chunk: break osbf.write(chunk) isbf.close() osbf.close() os.unlink(tfn) os.chmod(SCEPCLIENT, stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
Example #28
Source File: osx_package.py From zentral with Apache License 2.0 | 5 votes |
def create_file_with_content_string(self, rel_path, content, executable=False): filepath = self.get_root_path(rel_path) dirpath = os.path.dirname(filepath) if not os.path.exists(dirpath): os.makedirs(dirpath) with open(filepath, "wb") as f: f.write(content.encode("utf-8")) if executable: f_stat = os.stat(filepath) os.chmod(filepath, f_stat.st_mode | stat.S_IXUSR | stat.S_IWGRP | stat.S_IXOTH)
Example #29
Source File: utils.py From pipenv-sublime with MIT License | 5 votes |
def is_executable_file(path): """Checks that path is an executable regular file, or a symlink towards one. This is roughly ``os.path isfile(path) and os.access(path, os.X_OK)``. """ # follow symlinks, fpath = os.path.realpath(path) if not os.path.isfile(fpath): # non-files (directories, fifo, etc.) return False mode = os.stat(fpath).st_mode if (sys.platform.startswith('sunos') and os.getuid() == 0): # When root on Solaris, os.X_OK is True for *all* files, irregardless # of their executability -- instead, any permission bit of any user, # group, or other is fine enough. # # (This may be true for other "Unix98" OS's such as HP-UX and AIX) return bool(mode & (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)) return os.access(fpath, os.X_OK)
Example #30
Source File: ssh.py From django-gateone with GNU General Public License v3.0 | 5 votes |
def initialize(self): """ Called inside of :meth:`TerminalApplication.initialize` shortly after the WebSocket is instantiated. Attaches our two `terminal:authenticate` events (to create the user's .ssh dir and send our CSS template) and ensures that the ssh_connect.py script is executable. """ ssh_connect_path = os.path.join(PLUGIN_PATH, 'scripts', 'ssh_connect.py') if os.path.exists(ssh_connect_path): import stat st = os.stat(ssh_connect_path) if not bool(st.st_mode & stat.S_IXOTH): try: os.chmod(ssh_connect_path, 0o755) except OSError: ssh_log.error(_( "Could not set %s as executable. You will need to 'chmod " "a+x' that script manually.") % ssh_connect_path) user_msg = _( "Error loading SSH plugin: The ssh_connect.py script is " "not executable. See the logs for more details.") send_msg = partial(self.ws.send_message, user_msg) events = ["terminal:authenticate", "terminal:new_terminal"] self.on(events, send_msg) self.ssh_log = go_logger("gateone.terminal.ssh", plugin='ssh') # NOTE: Why not use the 'Events' hook for these? You can't attach two # functions to the same event via that mechanism because it's a dict # (one would override the other). # An alternative would be to write a single function say, on_auth() that # calls both of these functions then assign it to 'terminal:authenticate' in # the 'Events' hook. I think this way is better since it is more explicit. self.on('terminal:authenticate', bind(send_ssh_css_template, self)) self.on('terminal:authenticate', bind(create_user_ssh_dir, self))