id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
171,452
from __future__ import annotations import os import stat def raise_on_exist_ro_file(filename: str) -> None: try: file_stat = os.stat(filename) # use stat to do exists + can write to check without race condition except OSError: return None # swallow does not exist or other errors if file_...
null
171,453
import asyncio import concurrent.futures import inspect import itertools import logging import os import socket import sys import time import typing as t import uuid import warnings from datetime import datetime from functools import partial from signal import SIGINT, SIGTERM, Signals, default_int_handler, signal impor...
null
171,454
import errno import json import os import shutil import stat import sys import tempfile from jupyter_client.kernelspec import KernelSpecManager from traitlets import Unicode KERNEL_NAME = "python%i" % sys.version_info[0] def write_kernel_spec(path=None, overrides=None, extra_arguments=None): """Write a kernel spec ...
Install the IPython kernelspec for Jupyter Parameters ---------- kernel_spec_manager : KernelSpecManager [optional] A KernelSpecManager to use for installation. If none provided, a default instance will be created. user : bool [default: False] Whether to do a user-only install, or system-wide. kernel_name : str, option...
171,455
import json import sys from subprocess import PIPE, Popen from typing import Any, Dict import jupyter_client from jupyter_client import write_connection_file def _find_connection_file(connection_file): """Return the absolute path for a connection file - If nothing specified, return current Kernel's connection f...
Return the connection information for the current Kernel. Parameters ---------- connection_file : str [optional] The connection file to be used. Can be given by absolute path, or IPython will search in the security directory. If run from IPython, If unspecified, the connection file for the currently running IPython Ker...
171,456
import json import sys from subprocess import PIPE, Popen from typing import Any, Dict import jupyter_client from jupyter_client import write_connection_file def _find_connection_file(connection_file): """Return the absolute path for a connection file - If nothing specified, return current Kernel's connection f...
Connect a qtconsole to the current kernel. This is useful for connecting a second qtconsole to a kernel, or to a local notebook. Parameters ---------- connection_file : str [optional] The connection file to be used. Can be given by absolute path, or IPython will search in the security directory. If run from IPython, If...
171,457
import os import sys import tempfile from IPython.core.compilerop import CachingCompiler def _convert_to_long_pathname(filename): buf = ctypes.create_unicode_buffer(MAX_PATH) rv = _GetLongPathName(filename, buf, MAX_PATH) if rv != 0 and rv <= MAX_PATH: filename = buf...
null
171,458
import os import sys import tempfile from IPython.core.compilerop import CachingCompiler def murmur2_x86(data, seed): """Get the murmur2 hash.""" m = 0x5BD1E995 data = [chr(d) for d in str.encode(data, "utf8")] length = len(data) h = seed ^ length rounded_end = length & 0xFFFFFFFC for i in r...
Get a file name.
171,459
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application The provided code snippet includes necessary dependencies for implementing the `_use_appnope` function. Write a Python function `def _use_appnop...
Should we use appnope for dealing with OS X app nap? Checks if we are on OS X 10.9 or greater.
171,460
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application loop_map = { "inline": None, "nbagg": None, "webagg": None, "notebook": None, "ipympl": None, "widget": None, None: N...
Decorator to register an event loop to integrate with the IPython kernel The decorator takes names to register the event loop as for the %gui magic. You can provide alternative names for the same toolkit. The decorated function should take a single argument, the IPython kernel instance, arrange for the event loop to ca...
171,461
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application def _notify_stream_qt(kernel): import operator from functools import lru_cache from IPython.external.qt_for_kernel import QtCore ...
Event loop for all supported versions of Qt.
171,462
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application def loop_qt_exit(kernel): kernel.app.exit()
null
171,463
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application def _loop_wx(app): """Inner-loop for running the Wx eventloop Pulled from guisupport.start_event_loop in IPython < 5.2, since IPython...
Start a kernel with wx event loop support.
171,464
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application The provided code snippet includes necessary dependencies for implementing the `loop_wx_exit` function. Write a Python function `def loop_wx_exi...
Exit the wx loop.
171,465
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application class partial(Generic[_T]): func: Callable[..., _T] args: Tuple[Any, ...] keywords: Dict[str, Any] def __init__(self, func: Call...
Start a kernel with the Tk event loop.
171,466
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application The provided code snippet includes necessary dependencies for implementing the `loop_tk_exit` function. Write a Python function `def loop_tk_exi...
Exit the tk loop.
171,467
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application class GTKEmbed: """A class to embed a kernel into the GTK main event loop.""" def __init__(self, kernel): """Initialize the emb...
Start the kernel, coordinating with the GTK event loop
171,468
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application def stop(timer=None, loop=None): """Callback to fire when there's input to be read""" _triggered.set() NSApp = _NSApp() # if NSA...
Exit the gtk loop.
171,469
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application class GTKEmbed: """A class to embed a kernel into the GTK main event loop.""" def __init__(self, kernel): """Initialize the emb...
Start the kernel, coordinating with the GTK event loop
171,470
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application def stop(timer=None, loop=None): """Callback to fire when there's input to be read""" _triggered.set() NSApp = _NSApp() # if NSA...
Exit the gtk3 loop.
171,471
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application def stop(timer=None, loop=None): """Callback to fire when there's input to be read""" _triggered.set() NSApp = _NSApp() # if NSA...
Start the kernel, coordinating with the Cocoa CFRunLoop event loop via the matplotlib MacOSX backend.
171,472
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application def stop(timer=None, loop=None): """Callback to fire when there's input to be read""" _triggered.set() NSApp = _NSApp() # if NSA...
Exit the cocoa loop.
171,473
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application class partial(Generic[_T]): func: Callable[..., _T] args: Tuple[Any, ...] keywords: Dict[str, Any] def __init__(self, func: Call...
Start a kernel with asyncio event loop support.
171,474
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application def stop(timer=None, loop=None): """Callback to fire when there's input to be read""" _triggered.set() NSApp = _NSApp() # if NSA...
Exit hook for asyncio
171,475
import os import platform import sys from functools import partial import zmq from packaging.version import Version as V from traitlets.config.application import Application loop_map = { "inline": None, "nbagg": None, "webagg": None, "notebook": None, "ipympl": None, "widget": None, None: N...
Enable integration with a given GUI
171,476
import math import numbers import re import types from binascii import b2a_base64 from datetime import date, datetime from jupyter_client._version import version_info as jupyter_client_version The provided code snippet includes necessary dependencies for implementing the `encode_images` function. Write a Python functi...
b64-encodes images in a displaypub format dict Perhaps this should be handled in json_clean itself? Parameters ---------- format_dict : dict A dictionary of display data keyed by mime-type Returns ------- format_dict : dict A copy of the same dictionary, but binary image data ('image/png', 'image/jpeg' or 'application/...
171,477
import math import numbers import re import types from binascii import b2a_base64 from datetime import date, datetime from jupyter_client._version import version_info as jupyter_client_version next_attr_name = "__next__" ISO8601 = "%Y-%m-%dT%H:%M:%S.%f" datetime.strptime("1", "%d") JUPYTER_CLIENT_MAJOR_VERSION = jupyt...
Deprecated, this is a no-op for jupyter-client>=7. Clean an object to ensure it's safe to encode in JSON. Atomic, immutable objects are returned unmodified. Sets and tuples are converted to lists, lists are copied and dicts are also copied. Note: dicts whose keys could cause collisions upon encoding (such as a dict wit...
171,478
import asyncio import builtins import getpass import os import signal import sys import threading import typing as t from contextlib import contextmanager from functools import partial import comm from IPython.core import release from IPython.utils.tokenutil import line_at_cursor, token_at_cursor from traitlets import ...
Create a new Comm.
171,479
import asyncio import builtins import getpass import os import signal import sys import threading import typing as t from contextlib import contextmanager from functools import partial import comm from IPython.core import release from IPython.utils.tokenutil import line_at_cursor, token_at_cursor from traitlets import ...
Create a new CommManager.
171,480
import warnings warnings.warn( "ipykernel.datapub is deprecated. It has moved to ipyparallel.datapub", DeprecationWarning, stacklevel=2, ) from traitlets import Any, CBytes, Dict, Instance from traitlets.config import Configurable from ipykernel.jsonutil import json_clean from jupyter_client.session import ...
publish a data_message on the IOPub channel Parameters ---------- data : dict The data to be published. Think of it as a namespace.
171,481
import sys from IPython.utils.frame import extract_module_locals from .kernelapp import IPKernelApp def extract_module_locals(depth=0): """Returns (module, locals) of the function `depth` frames away from the caller""" f = sys._getframe(depth + 1) global_ns = f.f_globals module = sys.modules[global_ns[...
Embed and start an IPython kernel in a given scope. Parameters ---------- module : ModuleType, optional The module to load into IPython globals (default: caller) local_ns : dict, optional The namespace to load into IPython user namespace (default: caller) kwargs : dict, optional Further keyword args are relayed to the ...
171,482
import warnings import pickle from itertools import chain from jupyter_client.session import MAX_BYTES, MAX_ITEMS def serialize_object(obj, buffer_threshold=MAX_BYTES, item_threshold=MAX_ITEMS): """Serialize an object into a list of sendable buffers. Parameters ---------- obj : object The object...
pack up a function, args, and kwargs to be sent over the wire Each element of args/kwargs will be canned for special treatment, but inspection will not go any deeper than that. Any object whose data is larger than `threshold` will not have their data copied (only numpy arrays and bytes/buffers support zero-copy) Messag...
171,483
import warnings import pickle from itertools import chain from jupyter_client.session import MAX_BYTES, MAX_ITEMS def deserialize_object(buffers, g=None): """reconstruct an object serialized by serialize_object from data buffers. Parameters ---------- buffers : list of buffers/bytes g : globals to b...
unpack f,args,kwargs from buffers packed by pack_apply_message() Returns: original f,args,kwargs
171,484
import typing import warnings import copy import pickle import sys from types import FunctionType from ipyparallel.serialize import codeutil from traitlets.log import get_logger from traitlets.utils.importstring import import_item The provided code snippet includes necessary dependencies for implementing the `_get_ce...
the type of a closure cell doesn't seem to be importable, so just create one
171,485
import typing import warnings import copy import pickle import sys from types import FunctionType from ipyparallel.serialize import codeutil from traitlets.log import get_logger from traitlets.utils.importstring import import_item class FunctionType: __closure__: Optional[Tuple[_Cell, ...]] __code__: CodeType...
decorator for making functions appear as interactively defined. This results in the function being linked to the user_ns as globals() instead of the module globals().
171,486
import typing import warnings import copy import pickle import sys from types import FunctionType from ipyparallel.serialize import codeutil from traitlets.log import get_logger from traitlets.utils.importstring import import_item can_map = { "numpy.ndarray": CannedArray, FunctionType: CannedFunction, byte...
use dill to expand serialization support adds support for object methods and closures to serialization.
171,487
import typing import warnings import copy import pickle import sys from types import FunctionType from ipyparallel.serialize import codeutil from traitlets.log import get_logger from traitlets.utils.importstring import import_item can_map = { "numpy.ndarray": CannedArray, FunctionType: CannedFunction, byte...
use cloudpickle to expand serialization support adds support for object methods and closures to serialization.
171,488
import typing import warnings import copy import pickle import sys from types import FunctionType from ipyparallel.serialize import codeutil from traitlets.log import get_logger from traitlets.utils.importstring import import_item class_type = type class CannedClass(CannedObject): """A canned class object.""" ...
Can a class object.
171,489
import typing import warnings import copy import pickle import sys from types import FunctionType from ipyparallel.serialize import codeutil from traitlets.log import get_logger from traitlets.utils.importstring import import_item def istype(obj, check): """like isinstance(obj, check), but strict This won't ca...
can the *values* of a dict
171,490
import typing import warnings import copy import pickle import sys from types import FunctionType from ipyparallel.serialize import codeutil from traitlets.log import get_logger from traitlets.utils.importstring import import_item def istype(obj, check): """like isinstance(obj, check), but strict This won't ca...
Uncan a dict object.
171,491
import win32api import win32con import win32evtlog import win32evtlogutil import win32security def ReadLog(computer, logType="Application", dumpEachRecord=0): # read the entire log back. h = win32evtlog.OpenEventLog(computer, logType) numRecords = win32evtlog.GetNumberOfEventLogRecords(h) # prin...
null
171,492
import win32api import win32con import win32evtlog import win32evtlogutil import win32security def usage(): print("Writes an event to the event log.") print("-w : Dont write any test records.") print("-r : Dont read the event log") print("-c : computerName : Process the log on the specified computer")...
null
171,493
import sys import time import win32api import win32con import win32file import win32gui import win32gui_struct import winnt GUID_DEVINTERFACE_USB_DEVICE = "{A5DCBF10-6530-11D2-901F-00C04FB951ED}" def OnDeviceChange(hwnd, msg, wp, lp): # Unpack the 'lp' into the appropriate DEV_BROADCAST_* structure, # using the...
null
171,494
import struct import pythoncom import pywintypes import win32api import win32con import win32file from win32com import storagecon stream_types = { win32con.BACKUP_DATA: "Standard data", win32con.BACKUP_EA_DATA: "Extended attribute data", win32con.BACKUP_SECURITY_DATA: "Security descriptor data", win32co...
null
171,495
import win32con from pywin32_testutil import str2bytes from win32clipboard import * def TestEmptyClipboard(): OpenClipboard() try: EmptyClipboard() assert ( EnumClipboardFormats(0) == 0 ), "Clipboard formats were available after emptying it!" finally: CloseClipb...
null
171,496
import win32con from pywin32_testutil import str2bytes from win32clipboard import * def str2bytes(sval): def TestText(): OpenClipboard() try: text = "Hello from Python" text_bytes = str2bytes(text) SetClipboardText(text) got = GetClipboardData(win32con.CF_TEXT) # CF_TE...
null
171,497
import win32con from pywin32_testutil import str2bytes from win32clipboard import * cf_names = {} def TestClipboardEnum(): OpenClipboard() try: # Enumerate over the clipboard types enum = 0 while 1: enum = EnumClipboardFormats(enum) if enum == 0: ...
null
171,498
import win32con from pywin32_testutil import str2bytes from win32clipboard import * class Foo: def __init__(self, **kw): def __cmp__(self, other): def __eq__(self, other): def TestCustomFormat(): OpenClipboard() try: # Just for the fun of it pickle Python objects through the clipboard ...
null
171,499
import msvcrt import sys import threading import win32con from win32event import * from win32file import * def FindModem(): # Snoop over the comports, seeing if it is likely we have a modem. for i in range(1, 5): port = "COM%d" % (i,) try: handle = CreateFile( por...
null
171,500
import os import commctrl import win32api import win32con import win32gui import win32rcparser g_rcname = os.path.abspath( os.path.join(this_dir, "..", "test", "win32rcparser", "test.rc") ) class DemoWindow: def __init__(self, dlg_template): self.dlg_template = dlg_template def CreateWindow(self): ...
null
171,501
import win32api import win32file print(fsrc, fdst) win32file.CopyFileEx( fsrc, fdst, ProgressRoutine, Data=operation_desc, Cancel=False, CopyFlags=win32file.COPY_FILE_RESTARTABLE, Transaction=None, ) def ProgressRoutine( TotalFileSize, TotalBytesTransferred, StreamSize, Stre...
null
171,502
import math import random import time import win32api import win32con import win32gui def _MyCallback(hwnd, extra): hwnds, classes = extra hwnds.append(hwnd) classes[win32gui.GetClassName(hwnd)] = 1 print("Enumerating all windows...") print("Testing drawing functions ...") print("All tests done!") def Test...
null
171,503
import math import random import time import win32api import win32con import win32gui def OnPaint_1(hwnd, msg, wp, lp): dc, ps = win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) br = win32gui.CreateSolidBrush(win32api.RGB(255, 0, 0)) win32gui.SelectObject(dc, br) angle =...
null
171,504
import math import random import time import win32api import win32con import win32gui def OnPaint_2(hwnd, msg, wp, lp): dc, ps = win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) l, t, r, b = win32gui.GetClientRect(hwnd) for x in range(25): vertices = ( {...
null
171,505
import math import random import time import win32api import win32con import win32gui wndproc_1 = {win32con.WM_PAINT: OnPaint_1} def TestSetWorldTransform(): wc = win32gui.WNDCLASS() wc.lpszClassName = "test_win32gui_1" wc.style = win32con.CS_GLOBALCLASS | win32con.CS_VREDRAW | win32con.CS_HREDRAW wc.h...
null
171,506
import math import random import time import win32api import win32con import win32gui wndproc_2 = {win32con.WM_PAINT: OnPaint_2} def TestGradientFill(): wc = win32gui.WNDCLASS() wc.lpszClassName = "test_win32gui_2" wc.style = win32con.CS_GLOBALCLASS | win32con.CS_VREDRAW | win32con.CS_HREDRAW wc.hbrBac...
null
171,507
import time import timer import win32event import win32gui class glork: def __init__(self, delay=1000, max=10): self.x = 0 self.max = max self.id = timer.set_timer(delay, self.increment) # Could use the threading module, but this is # a win32 extension test after all! :-) ...
null
171,508
import msvcrt import os import win32api import win32con import win32event import win32gui import win32process import win32security The provided code snippet includes necessary dependencies for implementing the `logonUser` function. Write a Python function `def logonUser(loginString)` to solve the following problem: Lo...
Login as specified user and return handle. loginString: 'Domain\nUser\nPassword'; for local login use . or empty string as domain e.g. '.\nadministrator\nsecret_password'
171,509
import msvcrt import os import win32api import win32con import win32event import win32gui import win32process import win32security class Process: """ A Windows process. """ def __init__( self, cmd, login=None, hStdin=None, hStdout=None, hStderr=None, ...
Run cmd as a child process and return exit code. mSec: terminate cmd after specified number of milliseconds stdin, stdout, stderr: file objects for child I/O (use hStdin etc. to attach handles instead of files); default is caller's stdin, stdout & stderr; kw: see Process.__init__ for more keyword options
171,510
import sys import array import os import queue import struct import commctrl import win32api import win32con import win32gui_struct import winerror class DemoDialog(DemoWindowBase): def DoModal(self): def OnClose(self, hwnd, msg, wparam, lparam): def DemoModal(): w = DemoDialog() w.DoModal()
null
171,511
import sys import array import os import queue import struct import commctrl import win32api import win32con import win32gui_struct import winerror class DemoWindow(DemoWindowBase): def CreateWindow(self): # Create the window via CreateDialogBoxIndirect - it can then # work as a "normal" window, onc...
null
171,512
import getopt import os import sys import win32api import win32con import win32event import wincerapi def DumpPythonRegistry(): try: h = wincerapi.CeRegOpenKeyEx( win32con.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\PythonPath" % sys.winver, ) except win32api....
null
171,513
import getopt import os import sys import win32api import win32con import win32event import wincerapi def DumpRegistry(root, level=0): # A recursive dump of the remote registry to test most functions. h = wincerapi.CeRegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, None) level_prefix = " " * level index = 0 ...
null
171,514
import getopt import os import sys import win32api import win32con import win32event import wincerapi def DemoCopyFile(): # Create a file on the device, and write a string. cefile = wincerapi.CeCreateFile( "TestPython", win32con.GENERIC_WRITE, 0, None, win32con.OPEN_ALWAYS, 0, None ) wincerapi....
null
171,515
import getopt import os import sys import win32api import win32con import win32event import wincerapi def DemoCreateProcess(): try: hp, ht, pid, tid = wincerapi.CeCreateProcess( "Windows\\Python.exe", "", None, None, 0, 0, None, "", None ) # Not necessary, except to see if hand...
null
171,516
import getopt import os import sys import win32api import win32con import win32event import wincerapi def DumpRemoteMachineStatus(): ( ACLineStatus, BatteryFlag, BatteryLifePercent, BatteryLifeTime, BatteryFullLifeTime, BackupBatteryFlag, BackupBatteryLifePer...
null
171,517
import getopt import os import sys import win32api import win32con import win32event import wincerapi def DumpRemoteFolders(): # Dump all special folders possible. for name, val in list(wincerapi.__dict__.items()): if name[:6] == "CSIDL_": try: loc = str(wincerapi.CeGetSpeci...
null
171,518
import getopt import os import sys import win32api import win32con import win32event import wincerapi def usage(): print("Options:") print("-a - Execute all demos") print("-p - Execute Python process on remote device") print("-r - Dump the remote registry") print("-f - Dump all remote special folde...
null
171,519
import http.client import optparse import urllib.error import urllib.parse import urllib.request from base64 import decodestring, encodestring from sspi import ClientAuth options = None class ClientAuth(_BaseAuth): def __init__( self, pkg_name, # Name of the package to used. ...
null
171,520
import sys import win32security from sspi import ClientAuth, ServerAuth class ClientAuth(_BaseAuth): def __init__( self, pkg_name, # Name of the package to used. client_name=None, # User for whom credentials are used. auth_info=None, # or a tuple of (username, do...
null
171,521
import sspi import sspicon import win32api import win32security def lookup_ret_code(err): for k, v in list(sspicon.__dict__.items()): if k[0:6] in ("SEC_I_", "SEC_E_") and v == err: return k
null
171,522
import http.client import optparse import socketserver import struct import traceback import sspi import win32api import win32security def GetUserName(): try: return win32api.GetUserName() except win32api.error as details: # Seeing 'access denied' errors here for non-local users (presumably ...
null
171,523
import http.client import optparse import socketserver import struct import traceback import sspi import win32api import win32security options = None class SSPISocketServer(socketserver.TCPServer): def __init__(self, *args, **kw): socketserver.TCPServer.__init__(self, *args, **kw) self.sa = sspi.S...
null
171,524
import http.client import optparse import socketserver import struct import traceback import sspi import win32api import win32security options = None def _send_msg(s, m): s.send(struct.pack("i", len(m))) s.send(m) def _get_msg(s): size_data = s.recv(struct.calcsize("i")) if not size_data: retu...
null
171,525
import pywintypes import win32api import win32con import win32security import winerror from security_enums import ( SECURITY_IMPERSONATION_LEVEL, TOKEN_ELEVATION_TYPE, TOKEN_GROUP_ATTRIBUTES, TOKEN_PRIVILEGE_ATTRIBUTES, TOKEN_TYPE, ) lt = dump_token(th) if lt: print("\n\nlinked token info:") ...
null
171,526
import sys import pywintypes from ntsecuritycon import * from win32net import NetUserModalsGet from win32security import LookupAccountSid def LookupAliasFromRid(TargetComputer, Rid): # Sid is the same regardless of machine, since the well-known # BUILTIN domain is referenced. sid = pywintypes.SID() sid...
null
171,527
import sys import pywintypes from ntsecuritycon import * from win32net import NetUserModalsGet from win32security import LookupAccountSid def LookupUserGroupFromRid(TargetComputer, Rid): # get the account domain Sid on the target machine # note: if you were looking up multiple sids based on the same # acco...
null
171,528
import win32api import win32security import winerror from ntsecuritycon import * def GetDomainName(): try: tok = win32security.OpenThreadToken(win32api.GetCurrentThread(), TOKEN_QUERY, 1) except win32api.error as details: if details[0] != winerror.ERROR_NO_TOKEN: raise # att...
null
171,529
import os import win32api import win32file import winerror f = open(fname, "w") f.write("xxxxxxxxxxxxxxxx\n" * 32768) f.close() f = open(fname + ":stream_y", "w") f.write("yyyyyyyyyyyyyyyy\n" * 32768) f.close() f = open(fname + ":stream_z", "w") f.write("zzzzzzzzzzzzzzzz\n" * 32768) f.close() f = open(bkup_fname, "wb")...
null
171,530
import os import win32api import win32file import winerror f = open(fname, "w") f.write("xxxxxxxxxxxxxxxx\n" * 32768) f.close() f = open(fname + ":stream_y", "w") f.write("yyyyyyyyyyyyyyyy\n" * 32768) f.close() f = open(fname + ":stream_z", "w") f.write("zzzzzzzzzzzzzzzz\n" * 32768) f.close() f = open(bkup_fname, "wb")...
null
171,531
import _thread import traceback import pywintypes import servicemanager import win32con import win32service import win32serviceutil import winerror from ntsecuritycon import * from win32api import * from win32event import * from win32file import * from win32pipe import * def ApplyIgnoreError(fn, args): try: ...
null
171,532
import os import sys import traceback import pywintypes import win32api import winerror from win32event import * from win32file import * from win32pipe import * verbose = 0 def CallPipe(fn, args): ret = None retryCount = 0 while retryCount < 8: # Keep looping until user cancels. retryCount = retryC...
null
171,533
import os import sys import traceback import pywintypes import win32api import winerror from win32event import * from win32file import * from win32pipe import * verbose = 0 def CallPipe(fn, args): def testLargeMessage(server, size=4096): if verbose: print("Sending message of size %d" % (size)) msg = "*...
null
171,534
import os import sys import traceback import pywintypes import win32api import winerror from win32event import * from win32file import * from win32pipe import * def stressThread(server, numMessages, wait): def stressTestClient(server, numThreads, numMessages): import _thread thread_waits = [] for t_num in...
null
171,535
import win32con import win32service def EnumServices(): resume = 0 accessSCM = win32con.GENERIC_READ accessSrv = win32service.SC_MANAGER_ALL_ACCESS # Open Service Control Manager hscm = win32service.OpenSCManager(None, None, accessSCM) # Enumerate Service Control Manager DB typeFilter = ...
null
171,536
import getopt import sys import traceback import win32api import win32net import win32netcon import win32security server = None The provided code snippet includes necessary dependencies for implementing the `CreateUser` function. Write a Python function `def CreateUser()` to solve the following problem: Creates a new ...
Creates a new test user, then deletes the user
171,537
import getopt import sys import traceback import win32api import win32net import win32netcon import win32security server = None def verbose(msg): if verbose_level: print(msg) The provided code snippet includes necessary dependencies for implementing the `UserEnum` function. Write a Python function `def Us...
Enumerates all the local users
171,538
import getopt import sys import traceback import win32api import win32net import win32netcon import win32security server = None def verbose(msg): if verbose_level: print(msg) The provided code snippet includes necessary dependencies for implementing the `GroupEnum` function. Write a Python function `def G...
Enumerates all the domain groups
171,539
import getopt import sys import traceback import win32api import win32net import win32netcon import win32security server = None def verbose(msg): if verbose_level: print(msg) The provided code snippet includes necessary dependencies for implementing the `LocalGroupEnum` function. Write a Python function `...
Enumerates all the local groups
171,540
import getopt import sys import traceback import win32api import win32net import win32netcon import win32security server = None def verbose(msg): if verbose_level: print(msg) The provided code snippet includes necessary dependencies for implementing the `ServerEnum` function. Write a Python function `def ...
Enumerates all servers on the network
171,541
import getopt import sys import traceback import win32api import win32net import win32netcon import win32security server = None The provided code snippet includes necessary dependencies for implementing the `LocalGroup` function. Write a Python function `def LocalGroup(uname=None)` to solve the following problem: Crea...
Creates a local group, adds some members, deletes them, then removes the group
171,542
import getopt import sys import traceback import win32api import win32net import win32netcon import win32security server = None def verbose(msg): if verbose_level: print(msg) The provided code snippet includes necessary dependencies for implementing the `GetInfo` function. Write a Python function `def Get...
Dumps level 3 information about the current user
171,543
import getopt import sys import traceback import win32api import win32net import win32netcon import win32security server = None The provided code snippet includes necessary dependencies for implementing the `SetInfo` function. Write a Python function `def SetInfo(userName=None)` to solve the following problem: Attempt...
Attempts to change the current users comment, then set it back
171,544
import getopt import sys import traceback import win32api import win32net import win32netcon import win32security The provided code snippet includes necessary dependencies for implementing the `SetComputerInfo` function. Write a Python function `def SetComputerInfo()` to solve the following problem: Doesnt actually ch...
Doesnt actually change anything, just make sure we could ;-)
171,545
import getopt import sys import traceback import win32api import win32net import win32netcon import win32security def usage(tests): import os print("Usage: %s [-s server ] [-v] [Test ...]" % os.path.basename(sys.argv[0])) print(" -v : Verbose - print more information") print(" -s : server - execute ...
null
171,546
import os import win32api import win32con import win32file def SimpleFileDemo(): testName = os.path.join(win32api.GetTempPath(), "win32file_demo_test_file") if os.path.exists(testName): os.unlink(testName) # Open the file for writing. handle = win32file.CreateFile( testName, win32file.G...
null
171,547
import win32evtlog def c(reason, context, evt): if reason == win32evtlog.EvtSubscribeActionError: print("EvtSubscribeActionError") elif reason == win32evtlog.EvtSubscribeActionDeliver: print("EvtSubscribeActionDeliver") else: print("??? Unknown action ???", reason) context.appen...
null
171,548
import os import struct import win32api import win32con import win32file import win32transaction import winerror import winioctlcon from pywin32_testutil import str2bytes def str2bytes(sval): if sys.version_info < (3, 0) and isinstance(sval, str): sval = sval.decode("latin1") return sval.encode("latin1...
Definition of buffer used with FSCTL_TXFS_CREATE_MINIVERSION: typedef struct _TXFS_CREATE_MINIVERSION_INFO{ USHORT StructureVersion; USHORT StructureLength; ULONG BaseVersion; USHORT MiniVersion;}
171,549
def MEVT_EVENTTYPE(x): return (BYTE)(((x) >> 24) & 0xFF)
null
171,550
def MEVT_EVENTPARM(x): return (DWORD)((x) & 0x00FFFFFF)
null
171,551
def MCI_MSF_MINUTE(msf): return (BYTE)(msf)
null