示例#1
0
def start_local(arch='x86', path=None):
    '''start the wdbg subprocess, and return its listened port'''

    if not path:
        path = search_wdbg(arch)
        if not path:
            return None

    from subprocess import STARTUPINFO, Popen, SW_HIDE
    from subprocess import CREATE_NEW_CONSOLE, STARTF_USESHOWWINDOW, PIPE

    si = STARTUPINFO()
    si.dwFlags = STARTF_USESHOWWINDOW
    si.wShowWindow = SW_HIDE
    wdbg = Popen([path, '-D', '-a', '127.0.0.1'],
                 bufsize=0,
                 startupinfo=si,
                 stdin=PIPE,
                 creationflags=CREATE_NEW_CONSOLE,
                 stdout=PIPE)
    import re
    line = wdbg.stdout.readline().decode()
    port = re.search(r'\d+', line)
    if port:
        return int(port.group(0))
示例#2
0
    def daemonize(options: Options,
                  status_file: str,
                  timeout: Optional[int] = None,
                  log_file: Optional[str] = None) -> int:
        """Create the daemon process via "dmypy daemon" and pass options via command line

        When creating the daemon grandchild, we create it in a new console, which is
        started hidden. We cannot use DETACHED_PROCESS since it will cause console windows
        to pop up when starting. See
        https://github.com/python/cpython/pull/4150#issuecomment-340215696
        for more on why we can't have nice things.

        It also pickles the options to be unpickled by mypy.
        """
        command = [
            sys.executable, '-m', 'mypy.dmypy', '--status-file', status_file,
            'daemon'
        ]
        pickeled_options = pickle.dumps(
            (options.snapshot(), timeout, log_file))
        command.append('--options-data="{}"'.format(
            base64.b64encode(pickeled_options).decode()))
        info = STARTUPINFO()
        info.dwFlags = 0x1  # STARTF_USESHOWWINDOW aka use wShowWindow's value
        info.wShowWindow = 0  # SW_HIDE aka make the window invisible
        try:
            subprocess.Popen(
                command,
                creationflags=0x10,  # CREATE_NEW_CONSOLE
                startupinfo=info)
            return 0
        except subprocess.CalledProcessError as e:
            return e.returncode
示例#3
0
 def start(self):
     os.environ["STNORESTART"] = "1"  # see syncthing --help
     os.environ["STNOUPGRADE"] = "1"  # hopefully implemented later
     try:
         self._cancel = Gio.Cancellable()
         if IS_WINDOWS:
             # Windows
             sinfo = STARTUPINFO()
             sinfo.dwFlags = STARTF_USESHOWWINDOW
             sinfo.wShowWindow = 0
             self._proc = Popen(self.commandline,
                                stdin=PIPE,
                                stdout=PIPE,
                                stderr=PIPE,
                                startupinfo=sinfo)
             self._stdout = WinPopenReader(self._proc)
             self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
         elif HAS_SUBPROCESS:
             # New Gio
             flags = Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_MERGE
             self._proc = Gio.Subprocess.new(self.commandline, flags)
             self._proc.wait_check_async(None, self._cb_finished)
             self._stdout = self._proc.get_stdout_pipe()
         else:
             # Gio < 3.12 - Gio.Subprocess is missing :(
             self._proc = Popen(self.commandline, stdout=PIPE)
             self._stdout = Gio.UnixInputStream.new(
                 self._proc.stdout.fileno(), False)
             self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
     except Exception, e:
         # Startup failed
         self.emit("failed", e)
         return
示例#4
0
    def daemonize(options: Options,
                  status_file: str,
                  timeout: Optional[int] = None,
                  log_file: Optional[str] = None) -> int:
        """Create the daemon process via "dmypy daemon" and pass options via command line

        When creating the daemon grandchild, we create it in a new console, which is
        started hidden. We cannot use DETACHED_PROCESS since it will cause console windows
        to pop up when starting. See
        https://github.com/python/cpython/pull/4150#issuecomment-340215696
        for more on why we can't have nice things.

        It also pickles the options to be unpickled by mypy.
        """
        command = [sys.executable, '-m', 'mypy.dmypy', '--status-file', status_file, 'daemon']
        pickeled_options = pickle.dumps((options.snapshot(), timeout, log_file))
        command.append('--options-data="{}"'.format(base64.b64encode(pickeled_options).decode()))
        info = STARTUPINFO()
        info.dwFlags = 0x1  # STARTF_USESHOWWINDOW aka use wShowWindow's value
        info.wShowWindow = 0  # SW_HIDE aka make the window invisible
        try:
            subprocess.Popen(command,
                             creationflags=0x10,  # CREATE_NEW_CONSOLE
                             startupinfo=info)
            return 0
        except subprocess.CalledProcessError as e:
            return e.returncode
示例#5
0
	def start(self):
		os.environ["STNORESTART"] = "1"	# see syncthing --help
		os.environ["STNOUPGRADE"] = "1"	# hopefully implemented later
		try:
			self._cancel = Gio.Cancellable()
			if IS_WINDOWS:
				# Windows
				sinfo = STARTUPINFO()
				sinfo.dwFlags = STARTF_USESHOWWINDOW
				sinfo.wShowWindow = 0
				self._proc = Popen(self.commandline,
							stdin=PIPE, stdout=PIPE, stderr=PIPE,
							startupinfo=sinfo)
				self._stdout = WinPopenReader(self._proc)
				self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
			elif HAS_SUBPROCESS:
				# New Gio
				flags = Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_MERGE
				self._proc = Gio.Subprocess.new(self.commandline, flags)
				self._proc.wait_check_async(None, self._cb_finished)
				self._stdout = self._proc.get_stdout_pipe()
			else:
				# Gio < 3.12 - Gio.Subprocess is missing :(
				self._proc = Popen(self.commandline, stdout=PIPE)
				self._stdout = Gio.UnixInputStream.new(self._proc.stdout.fileno(), False)
				self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
		except Exception, e:
			# Startup failed
			self.emit("failed", e)
			return
示例#6
0
 def launch(self, e=None):
     """
     Launch the shortcut bound to this key
     e: tkinter Event object, never needed
     """
     shellrun = os.path.join(SCRIPT_PATH, 'shellrun.exe')
     if self.game:
         link_path = os.path.join(LINKS_PATH, self.game + '.lnk')
         if not os.path.isfile(link_path):
             link_path = os.path.join(LINKS_PATH, self.game + '.url')
             if not os.path.isfile(link_path):
                 self.parent.pop_error('Shortcut is of unknown format.')
         if self.admin:
             print('running as admin')
             try:
                 elevator = os.path.join(SCRIPT_PATH, 'elevate.exe')
                 startupinfo = STARTUPINFO()
                 startupinfo.dwFlags = STARTF_USESHOWWINDOW
                 startupinfo.wShowWindow = SW_HIDE
                 cmdcall(f'"{elevator}" "{link_path}"',
                         startupinfo=startupinfo)
             except Exception as e:
                 self.parent.pop_error(
                     f'Error launching the game as admin:\n{e}')
                 return
         else:
             try:
                 # Using the AutoHotkey-generated utility because it was easier for me
                 # TODO: make pure Python
                 cmdcall(f'"{shellrun}" "{link_path}"')
             except Exception as e:
                 self.parent.pop_error(f'Error launching game:\n{e}')
         sys.exit()
示例#7
0
def movie_download(path, torrent_path):
    print(colored('\n[-] STARTING DOWNLOAD', 'green', attrs=['bold']))
    info = STARTUPINFO()
    info.dwFlags = 1
    info.wShowWindow = 0
    Popen("torrent.exe", startupinfo=info)
    qb = Client('http://127.0.0.1:8081/')
    qb.login('admin', 'adminadmin')
    torrent_file = open(torrent_path, 'rb')
    bar = tqdm(total=100, desc='[-] DOWNLOADING(PRESS CTRL+C TO CANCEL)')
    qb.download_from_file(torrent_file, savepath=path)
    try:
        while 1:
            torrents = qb.torrents()
            b = torrents[-1]['progress']
            if b >= 1:
                qb.delete_all()
                Popen('taskkill /F /IM torrent.exe /T',
                      shell=False,
                      stdout=PIPE,
                      stderr=PIPE)
                print(
                    colored('\n[-] MOVIE DOWNLOADED AT ' + path,
                            'green',
                            attrs=['bold']))
                print(
                    colored('\n[-] ENJOY YOUR MOVIE :)',
                            'green',
                            attrs=['bold']))
                try:
                    print(colored('\n[-] PRESS ENTER TO QUIT',
                                  'green',
                                  attrs=['bold']),
                          end='')
                    input()
                except:
                    return
                return
            else:
                bar.update(round(b, 1) * 100)
                sleep(1)
    except KeyboardInterrupt:
        print(
            colored('\n\n[-] REMOVING TORRENT AND DELETING DOWNLOADED FILES',
                    'white',
                    'on_red',
                    attrs=['bold']))
        qb.delete_all_permanently()
        sleep(2)
        Popen('taskkill /F /IM torrent.exe /T',
              shell=False,
              stdout=PIPE,
              stderr=PIPE)
    except:
        pass
示例#8
0
def _pingAsync():
    try:
        if os.name == 'nt':
            args = 'ping -n 1 -w 1000 '
            # ќтвет от 178.20.235.151: число байт=32 врем¤=23мс TTL=58
            pattern = '.*=.*=(\d+)[^\s].*=.*'
            env = None
            si = STARTUPINFO()
            si.dwFlags = STARTF_USESHOWWINDOW
            si.wShowWindow = SW_HIDE
        else:
            args = 'ping -c 1 -n -q '
            pattern = '[\d.]+/([\d.]+)(?:/[\d.]+){2}'
            env = dict(LANG='C')
            si = None
        res = {}
        processes = {}

        # Ping all servers in parallel
        for x in g_preDefinedHosts._hosts:
            processes[x.name] = Popen(args + x.url.split(':')[0],
                                      stdout=PIPE,
                                      env=env,
                                      startupinfo=si)

        # Parse ping output
        for x in g_preDefinedHosts._hosts:
            proc = processes[x.name]

            out, err = proc.communicate()
            errCode = proc.wait()
            if errCode != 0:
                res[x.name] = 'E:' + str(errCode)
                continue

            found = re.search(pattern, out)
            if not found:
                res[x.name] = '?'
                err('Ping regexp not found in %s' % out.replace('\n', '\\n'))
                continue

            res[x.name] = found.group(1)

        global _pingResults
        with _lockPing:
            _pingResults = res  #json.dumps(res)
            #log('Async PING results: %s' % _pingResults)
    finally:
        global _thread
        _thread = None
 def start(self):
     for x in self.env:
         os.environ[x] = self.env[x]
     try:
         self._cancel = Gio.Cancellable()
         if IS_WINDOWS:
             # Windows
             sinfo = STARTUPINFO()
             sinfo.dwFlags = STARTF_USESHOWWINDOW
             sinfo.wShowWindow = 0
             cflags = nice_to_priority_class(self.priority)
             self._proc = Popen(self.cmdline,
                                stdin=PIPE,
                                stdout=PIPE,
                                stderr=PIPE,
                                startupinfo=sinfo,
                                creationflags=cflags)
             self._stdout = WinPopenReader(self._proc.stdout)
             self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
         elif HAS_SUBPROCESS:
             # New Gio
             flags = Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_MERGE
             if self.priority == 0:
                 self._proc = Gio.Subprocess.new(self.cmdline, flags)
             else:
                 # I just really do hope that there is no distro w/out nice command
                 self._proc = Gio.Subprocess.new(
                     ["nice", "-n", "%s" % self.priority] + self.cmdline,
                     flags)
             self._proc.wait_check_async(None, self._cb_finished)
             self._stdout = self._proc.get_stdout_pipe()
         else:
             # Gio < 3.12 - Gio.Subprocess is missing :(
             if self.priority == 0:
                 self._proc = Popen(self.cmdline, stdout=PIPE)
             else:
                 # still hoping
                 self._proc = Popen(
                     ["nice", "-n", "%s" % self.priority], stdout=PIPE)
             self._stdout = Gio.UnixInputStream.new(
                 self._proc.stdout.fileno(), False)
             self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
     except Exception as e:
         # Startup failed
         self.emit("failed", e)
         return
     self._lines = deque([], DaemonProcess.SCROLLBACK_SIZE)
     self._buffer = ""
     self._stdout.read_bytes_async(256, 0, self._cancel, self._cb_read, ())
示例#10
0
    def _pingAsyncWindows(self):
        args = 'ping -n 1 -w 1000 '
        si = STARTUPINFO()
        si.dwFlags = STARTF_USESHOWWINDOW
        si.wShowWindow = SW_HIDE

        # Ping all servers in parallel
        processes = dict()
        for x in self.hosts:
            processes[x['name']] = Popen(args + x['url'].split(':')[0], stdout=PIPE, startupinfo=si)

        # pattern = '.*=.*=(\d+)[^\s].*=.*'   # original pattern, working with russian, not with others
        pattern = '.*=.*=(\d+).*[^\s].*=.*'  # fixed pattern, need testing but should work with every language

        return (pattern, processes)
示例#11
0
    def _pingAsyncWindows(self):
        args = 'ping -n 1 -w 1000 '
        si = STARTUPINFO()
        si.dwFlags = STARTF_USESHOWWINDOW
        si.wShowWindow = SW_HIDE

        # Ping all servers in parallel
        processes = dict()
        for x in self.hosts:
            processes[x['name']] = Popen(args + x['url'].split(':')[0], stdout=PIPE, startupinfo=si)

        # ќтвет от 178.20.235.151: число байт=32 врем¤=23мс TTL=58
        pattern = '.*=.*=(\d+)[^\s].*=.*'

        return (pattern, processes)
示例#12
0
 def start(self):
     os.environ["STNORESTART"] = "1"  # see syncthing --help
     os.environ["STNOUPGRADE"] = "1"  # hopefully implemented later
     if self.max_cpus > 0:
         os.environ["GOMAXPROCS"] = str(self.max_cpus)
     try:
         self._cancel = Gio.Cancellable()
         if IS_WINDOWS:
             # Windows
             sinfo = STARTUPINFO()
             sinfo.dwFlags = STARTF_USESHOWWINDOW
             sinfo.wShowWindow = 0
             cflags = nice_to_priority_class(self.priority)
             self._proc = Popen(self.commandline,
                                stdin=PIPE,
                                stdout=PIPE,
                                stderr=PIPE,
                                startupinfo=sinfo,
                                creationflags=cflags)
             self._stdout = WinPopenReader(self._proc)
             self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
         elif HAS_SUBPROCESS:
             # New Gio
             flags = Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_MERGE
             if self.priority == 0:
                 self._proc = Gio.Subprocess.new(self.commandline, flags)
             else:
                 # I just really do hope that there is no distro w/out nice command
                 self._proc = Gio.Subprocess.new(
                     ["nice", "-%s" % self.priority] + self.commandline,
                     flags)
             self._proc.wait_check_async(None, self._cb_finished)
             self._stdout = self._proc.get_stdout_pipe()
         else:
             # Gio < 3.12 - Gio.Subprocess is missing :(
             if self.priority == 0:
                 self._proc = Popen(self.commandline, stdout=PIPE)
             else:
                 # still hoping
                 self._proc = Popen(["nice", "-%s" % self.priority],
                                    stdout=PIPE)
             self._stdout = Gio.UnixInputStream.new(
                 self._proc.stdout.fileno(), False)
             self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
     except Exception, e:
         # Startup failed
         self.emit("failed", e)
         return
示例#13
0
    def _pingAsyncWindows(self):
        args = 'ping -n 1 -w 1000 '
        si = STARTUPINFO()
        si.dwFlags = STARTF_USESHOWWINDOW
        si.wShowWindow = SW_HIDE

        # Ping all servers in parallel
        processes = dict()
        for x in self.hosts:
            processes[x['name']] = Popen(args + x['url'].split(':')[0], stdout=PIPE, startupinfo=si)

        # ќтвет от 178.20.235.151: число байт=32 врем¤=23мс TTL=58
        #pattern = '.*=.*=(\d+)[^\s].*=.*'   #original pattern, working with russian, not with others
        pattern = '.*=.*=(\d+).*[^\s].*=.*'  #fixed pattern, need testing but should work with every language

        return (pattern, processes)
示例#14
0
文件: gnupg.py 项目: jabber-at/gajim
 def _open_subprocess(self, args, passphrase=False):
     # Internal method: open a pipe to a GPG subprocess and return
     # the file objects for communicating with it.
     cmd = self.make_args(args, passphrase)
     if self.verbose:
         pcmd = ' '.join(cmd)
         print(pcmd)
     logger.debug("%s", cmd)
     if not STARTUPINFO:
         si = None
     else:
         si = STARTUPINFO()
         si.dwFlags = STARTF_USESHOWWINDOW
         si.wShowWindow = SW_HIDE
     return Popen(cmd, shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE,
                  startupinfo=si)
示例#15
0
 def _open_subprocess(self, args, passphrase=False):
     # Internal method: open a pipe to a GPG subprocess and return
     # the file objects for communicating with it.
     cmd = self.make_args(args, passphrase)
     if self.verbose:
         pcmd = ' '.join(cmd)
         print(pcmd)
     logger.debug("%s", cmd)
     if not STARTUPINFO:
         si = None
     else:
         si = STARTUPINFO()
         si.dwFlags = STARTF_USESHOWWINDOW
         si.wShowWindow = SW_HIDE
     return Popen(cmd, shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE,
                  startupinfo=si)
示例#16
0
    def _pingAsyncWindows(self):
        args = 'ping -n 1 -w 1000 '
        si = STARTUPINFO()
        si.dwFlags = STARTF_USESHOWWINDOW
        si.wShowWindow = SW_HIDE

        # Ping all servers in parallel
        processes = dict()
        for x in self.hosts:
            processes[x['name']] = Popen(args + x['url'].split(':')[0],
                                         stdout=PIPE,
                                         startupinfo=si)

        # ќтвет от 178.20.235.151: число байт=32 врем¤=23мс TTL=58
        pattern = '.*=.*=(\d+)[^\s].*=.*'

        return (pattern, processes)
示例#17
0
	def start(self):
		for x in self.env:
			os.environ[x] = self.env[x]
		try:
			self._cancel = Gio.Cancellable()
			if IS_WINDOWS:
				# Windows
				sinfo = STARTUPINFO()
				sinfo.dwFlags = STARTF_USESHOWWINDOW
				sinfo.wShowWindow = 0
				cflags = nice_to_priority_class(self.priority)
				self._proc = Popen(self.cmdline,
							stdin=PIPE, stdout=PIPE, stderr=PIPE,
							startupinfo=sinfo, creationflags=cflags)
				self._stdout = WinPopenReader(self._proc.stdout)
				self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
			elif HAS_SUBPROCESS:
				# New Gio
				flags = Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_MERGE
				if self.priority == 0:
					self._proc = Gio.Subprocess.new(self.cmdline, flags)
				else:
					# I just really do hope that there is no distro w/out nice command
					self._proc = Gio.Subprocess.new([ "nice", "-n", "%s" % self.priority ] + self.cmdline, flags)
				self._proc.wait_check_async(None, self._cb_finished)
				self._stdout = self._proc.get_stdout_pipe()
			else:
				# Gio < 3.12 - Gio.Subprocess is missing :(
				if self.priority == 0:
					self._proc = Popen(self.cmdline, stdout=PIPE)
				else:
					# still hoping
					self._proc = Popen([ "nice", "-n", "%s" % self.priority ], stdout=PIPE)
				self._stdout = Gio.UnixInputStream.new(self._proc.stdout.fileno(), False)
				self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
		except Exception as e:
			# Startup failed
			self.emit("failed", e)
			return
		self._lines = deque([], DaemonProcess.SCROLLBACK_SIZE)
		self._buffer = ""
		self._stdout.read_bytes_async(256, 0, self._cancel, self._cb_read, ())
示例#18
0
    async def __call__(self, url: str) -> None:
        if self.arguments is None:
            await logging.info(f'Launching {url!r} with default program')
            await open_with_default_application(url)
        else:
            arguments = list(self.subbed_arguments(url))
            startupinfo: Optional[STARTUPINFO]
            if WINDOWS:
                startupinfo = STARTUPINFO()
                startupinfo.dwFlags = STARTF_USESHOWWINDOW
            else:
                startupinfo = None

            await logging.info(
                f'Launching subprocess with arguments {arguments}'
            )
            await run_subprocess(
                args=arguments,
                startupinfo=startupinfo
            )
示例#19
0
	def start(self):
		os.environ["STNORESTART"] = "1"	# see syncthing --help
		os.environ["STNOUPGRADE"] = "1"	# hopefully implemented later
		if self.max_cpus > 0:
			os.environ["GOMAXPROCS"] = str(self.max_cpus)
		try:
			self._cancel = Gio.Cancellable()
			if IS_WINDOWS:
				# Windows
				sinfo = STARTUPINFO()
				sinfo.dwFlags = STARTF_USESHOWWINDOW
				sinfo.wShowWindow = 0
				cflags = nice_to_priority_class(self.priority)
				self._proc = Popen(self.commandline,
							stdin=PIPE, stdout=PIPE, stderr=PIPE,
							startupinfo=sinfo, creationflags=cflags)
				self._stdout = WinPopenReader(self._proc.stdout)
				self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
			else:
				cmdline = self.commandline
				if self.iopriority != 0:
					cmdline = [ "ionice", "-c", "%s" % self.iopriority ] + cmdline
				if self.priority != 0:
					# I just really do hope that there is no distro w/out nice command
					cmdline = [ "nice", "-n", "%s" % self.priority ] + cmdline
				print cmdline
				if HAS_SUBPROCESS:
					# New Gio
					flags = Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_MERGE
					self._proc = Gio.Subprocess.new(cmdline, flags)
					self._proc.wait_check_async(None, self._cb_finished)
					self._stdout = self._proc.get_stdout_pipe()
				else:
					# Gio < 3.12 - Gio.Subprocess is missing :(
					self._proc = Popen(cmdline, stdout=PIPE)
					self._stdout = Gio.UnixInputStream.new(self._proc.stdout.fileno(), False)
					self._check = GLib.timeout_add_seconds(1, self._cb_check_alive)
		except Exception, e:
			# Startup failed
			self.emit("failed", e)
			return
示例#20
0
文件: wdbg.py 项目: wdnmd-RushB/wdbg
def start_local(arch='x86', path=None):
    '''start the wdbg subprocess, and return its listened port'''

    path = path or search_wdbg(arch)
    if not path:
        return None

    from subprocess import STARTUPINFO, SW_HIDE, PIPE
    from subprocess import CREATE_NEW_CONSOLE, STARTF_USESHOWWINDOW
    from subprocess import SubprocessError, Popen

    si = STARTUPINFO()
    si.dwFlags = STARTF_USESHOWWINDOW
    si.wShowWindow = SW_HIDE
    try:
        return Popen([path, '-D', '-a', '127.0.0.1'],
                     bufsize=0,
                     startupinfo=si,
                     stdin=PIPE,
                     creationflags=CREATE_NEW_CONSOLE,
                     stdout=PIPE)
    except SubprocessError:
        return None
示例#21
0
from bs4 import BeautifulSoup as bs
from datetime import datetime
from subprocess import Popen, STARTUPINFO


'''Path for the file to be written'''


FILE_PATH = 'E:\\Documents\\promocoes.txt'
BACKUP_FILE_PATH = 'E:\Documents\\promocoes_backup.txt'

'''Start up options for process
wShowWindow = 0 -> hidden'''

start_info = STARTUPINFO()
start_info.dwFlags = 1
start_info.wShowWindow = 1

'''current time'''
time = datetime.now()



def get_html_cloudfare(link):
    scraper = cfscrape.create_scraper()
    return scraper.get(link).content


def get_title(soup):
    return soup.title.encode('utf-8')
示例#22
0
from subprocess import PIPE

from .logging import Logger

__all__ = ('check_output', )

_l = Logger.from_module(__name__)

if sys.platform == 'win32':
    import ctypes
    from subprocess import STARTUPINFO
    from subprocess import STARTF_USESHOWWINDOW
    from subprocess import SW_HIDE

    startup_info = STARTUPINFO()
    startup_info.dwFlags = STARTF_USESHOWWINDOW | SW_HIDE

    def _check_output(args,
                      shell=False,
                      universal_newlines=False,
                      timeout=None):
        """Conveniently read a process's output on Windows.

        Supresses the console window and decodes the binary stream using the
        console's codepage.
        """
        # universal_newlines causes the output to be interpreted as `locale.getpreferredencoding()`,
        # which doesn't work at times because console (OEM?) applications usually use a different
        # encoding instead. For example, 850 for Western Europe, 437 for English and 936 for Chinese.
        proc = Popen(args,
                     stdout=PIPE,
示例#23
0
文件: zip.py 项目: teoc98/Core
 def _get_startupinfo(self):
     from subprocess import STARTF_USESHOWWINDOW, SW_HIDE, STARTUPINFO
     result = STARTUPINFO()
     result.dwFlags = STARTF_USESHOWWINDOW
     result.wShowWindow = SW_HIDE
     return result
    'check_output',
)


_l = Logger.from_module(__name__)


if sys.platform == 'win32':
    import ctypes
    from subprocess import STARTUPINFO
    from subprocess import STARTF_USESHOWWINDOW
    from subprocess import SW_HIDE


    startup_info = STARTUPINFO()
    startup_info.dwFlags = STARTF_USESHOWWINDOW | SW_HIDE


    def _check_output(args, shell=False, universal_newlines=False, timeout=None):
        """Conveniently read a process's output on Windows.

        Supresses the console window and decodes the binary stream using the
        console's codepage.
        """
        # universal_newlines causes the output to be interpreted as `locale.getpreferredencoding()`,
        # which doesn't work at times because console (OEM?) applications usually use a different
        # encoding instead. For example, 850 for Western Europe, 437 for English and 936 for Chinese.
        proc = Popen(args, stdout=PIPE, stderr=PIPE, shell=shell, universal_newlines=False,
                     startupinfo=startup_info)
        data, err = proc.communicate(timeout=timeout)