Unnamed: 0
int64
0
10k
function
stringlengths
79
138k
label
stringclasses
20 values
info
stringlengths
42
261
6,500
def comment_line(path, regex, char='#', cmnt=True, backup='.bak'): r''' Comment or Uncomment a line in a text file. :param path: string The full path to the text file. :param regex: string A regex expression that begin...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/comment_line
6,501
def _mkstemp_copy(path, preserve_inode=True): ''' Create a temp file and move/copy the contents of ``path`` to the temp file. Return the path to the temp file. path The full path to the file whose contents will be moved/copied to a temp file. Whether it's moved or copi...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/_mkstemp_copy
6,502
def line(path, content, match=None, mode=None, location=None, before=None, after=None, show_changes=True, backup=False, quiet=False, indent=True): ''' .. versionadded:: 2015.8.0 Edit a line in the configuration file. :param path: Filesystem path to the file to be edited. ...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/line
6,503
def replace(path, pattern, repl, count=0, flags=8, bufsize=1, append_if_not_found=False, prepend_if_not_found=False, not_found_content=None, backup='.bak', dry_run=False, search_only=False...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/replace
6,504
def contains(path, text): ''' .. deprecated:: 0.17.0 Use :func:`search` instead. Return ``True`` if the file at ``path`` contains ``text`` CLI Example: .. code-block:: bash salt '*' file.contains /etc/crontab 'mymaintenance.sh' ''' path = os.path.expanduser(path) if n...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/contains
6,505
def contains_regex(path, regex, lchar=''): ''' .. deprecated:: 0.17.0 Use :func:`search` instead. Return True if the given regular expression matches on any line in the text of a given file. If the lchar argument (leading char) is specified, it will strip `lchar` from the left side of e...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/contains_regex
6,506
def contains_glob(path, glob_expr): ''' .. deprecated:: 0.17.0 Use :func:`search` instead. Return ``True`` if the given glob matches a string in the named file CLI Example: .. code-block:: bash salt '*' file.contains_glob /etc/foobar '*cheese*' ''' path = os.path.expanduse...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/contains_glob
6,507
def append(path, *args, **kwargs): ''' .. versionadded:: 0.9.5 Append text to the end of a file path path to file `*args` strings to append to file CLI Example: .. code-block:: bash salt '*' file.append /etc/motd \\ "With all thine offerings thou...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/append
6,508
def prepend(path, *args, **kwargs): ''' .. versionadded:: 2014.7.0 Prepend text to the beginning of a file path path to file `*args` strings to prepend to the file CLI Example: .. code-block:: bash salt '*' file.prepend /etc/motd \\ "With all thi...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/prepend
6,509
def touch(name, atime=None, mtime=None): ''' .. versionadded:: 0.9.5 Just like the ``touch`` command, create a file if it doesn't exist or simply update the atime and mtime if it already does. atime: Access time in Unix epoch time mtime: Last modification in Unix epoch time ...
TypeError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/touch
6,510
def link(src, path): ''' .. versionadded:: 2014.1.0 Create a hard link to a file CLI Example: .. code-block:: bash salt '*' file.link /path/to/file /path/to/link ''' src = os.path.expanduser(src) if not os.path.isabs(src): raise SaltInvocationError('File path must be...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/link
6,511
def symlink(src, path): ''' Create a symbolic link (symlink, soft link) to a file CLI Example: .. code-block:: bash salt '*' file.symlink /path/to/file /path/to/link ''' path = os.path.expanduser(path) if not os.path.isabs(path): raise SaltInvocationError('File path must ...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/symlink
6,512
def rename(src, dst): ''' Rename a file or directory CLI Example: .. code-block:: bash salt '*' file.rename /path/to/src /path/to/dst ''' src = os.path.expanduser(src) dst = os.path.expanduser(dst) if not os.path.isabs(src): raise SaltInvocationError('File path must b...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/rename
6,513
def copy(src, dst, recurse=False, remove_existing=False): ''' Copy a file or directory from source to dst In order to copy a directory, the recurse flag is required, and will by default overwrite files in the destination with the same path, and retain all other existing files. (similar to cp -r on ...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/copy
6,514
def statvfs(path): ''' .. versionadded:: 2014.1.0 Perform a statvfs call against the filesystem that the file resides on CLI Example: .. code-block:: bash salt '*' file.statvfs /path/to/file ''' path = os.path.expanduser(path) if not os.path.isabs(path): raise SaltIn...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/statvfs
6,515
def stats(path, hash_type=None, follow_symlinks=True): ''' Return a dict containing the stats for a given file CLI Example: .. code-block:: bash salt '*' file.stats /etc/passwd ''' path = os.path.expanduser(path) ret = {} if not os.path.exists(path): try: ...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/stats
6,516
def rmdir(path): ''' .. versionadded:: 2014.1.0 Remove the specified directory. Fails if a directory is not empty. CLI Example: .. code-block:: bash salt '*' file.rmdir /tmp/foo/ ''' path = os.path.expanduser(path) if not os.path.isabs(path): raise SaltInvocationErro...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/rmdir
6,517
def remove(path): ''' Remove the named file. If a directory is supplied, it will be recursively deleted. CLI Example: .. code-block:: bash salt '*' file.remove /tmp/foo ''' path = os.path.expanduser(path) if not os.path.isabs(path): raise SaltInvocationError('File pat...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/remove
6,518
def get_selinux_context(path): ''' Get an SELinux context from a given path CLI Example: .. code-block:: bash salt '*' file.get_selinux_context /etc/hosts ''' out = __salt__['cmd.run'](['ls', '-Z', path], python_shell=False) try: ret = re.search(r'\w+:\w+:\w+:\w+', out).g...
AttributeError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/get_selinux_context
6,519
def get_managed( name, template, source, source_hash, user, group, mode, saltenv, context, defaults, skip_verify, **kwargs): ''' Return the managed file data for file.managed name location where the file...
TypeError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/get_managed
6,520
def check_perms(name, ret, user, group, mode, follow_symlinks=False): ''' Check the permissions on files and chown if needed CLI Example: .. code-block:: bash salt '*' file.check_perms /etc/sudoers '{}' root root 400 .. versionchanged:: 2014.1.3 ``follow_symlinks`` option added ...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/check_perms
6,521
def manage_file(name, sfn, ret, source, source_sum, user, group, mode, saltenv, backup, makedirs=False, template=None, # pylint: disable=W0613...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/manage_file
6,522
def makedirs_perms(name, user=None, group=None, mode='0755'): ''' Taken and modified from os.makedirs to set user, group and mode for each directory created. CLI Example: .. code-block:: bash salt '*' file.makedirs_perms /opt/code ...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/makedirs_perms
6,523
def is_chrdev(name): ''' Check if a file exists and is a character device. CLI Example: .. code-block:: bash salt '*' file.is_chrdev /dev/chr ''' name = os.path.expanduser(name) stat_structure = None try: stat_structure = os.stat(name) except __HOLE__ as exc: ...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/is_chrdev
6,524
def mknod_chrdev(name, major, minor, user=None, group=None, mode='0660'): ''' .. versionadded:: 0.17.0 Create a character device. CLI Example: .. code-block:: bash salt '*' file.mknod_chrdev /dev/chr 180 ...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/mknod_chrdev
6,525
def is_blkdev(name): ''' Check if a file exists and is a block device. CLI Example: .. code-block:: bash salt '*' file.is_blkdev /dev/blk ''' name = os.path.expanduser(name) stat_structure = None try: stat_structure = os.stat(name) except __HOLE__ as exc: i...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/is_blkdev
6,526
def mknod_blkdev(name, major, minor, user=None, group=None, mode='0660'): ''' .. versionadded:: 0.17.0 Create a block device. CLI Example: .. code-block:: bash salt '*' file.mknod_blkdev /dev/blk 8 999 ...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/mknod_blkdev
6,527
def is_fifo(name): ''' Check if a file exists and is a FIFO. CLI Example: .. code-block:: bash salt '*' file.is_fifo /dev/fifo ''' name = os.path.expanduser(name) stat_structure = None try: stat_structure = os.stat(name) except __HOLE__ as exc: if exc.errno...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/is_fifo
6,528
def mknod_fifo(name, user=None, group=None, mode='0660'): ''' .. versionadded:: 0.17.0 Create a FIFO pipe. CLI Example: .. code-block:: bash salt '*' file.mknod_fifo /dev/fifo ''' name = os.path.expanduser(name) ret = {'name': name...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/mknod_fifo
6,529
def list_backups(path, limit=None): ''' .. versionadded:: 0.17.0 Lists the previous versions of a file backed up using Salt's :doc:`file state backup </ref/states/backup_mode>` system. path The path on the minion to check for backups limit Limit the number of results to the mos...
ValueError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/list_backups
6,530
def list_backups_dir(path, limit=None): ''' Lists the previous versions of a directory backed up using Salt's :doc:`file state backup </ref/states/backup_mode>` system. path The directory on the minion to check for backups limit Limit the number of results to the most recent N backu...
ValueError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/list_backups_dir
6,531
def restore_backup(path, backup_id): ''' .. versionadded:: 0.17.0 Restore a previous version of a file that was backed up using Salt's :doc:`file state backup </ref/states/backup_mode>` system. path The path on the minion to check for backups backup_id The numeric id for the ba...
KeyError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/restore_backup
6,532
def delete_backup(path, backup_id): ''' .. versionadded:: 0.17.0 Delete a previous version of a file that was backed up using Salt's :doc:`file state backup </ref/states/backup_mode>` system. path The path on the minion to check for backups backup_id The numeric id for the back...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/delete_backup
6,533
def grep(path, pattern, *opts): ''' Grep for a string in the specified file .. note:: This function's return value is slated for refinement in future versions of Salt path Path to the file to be searched .. note:: Globbing is supported (i....
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/grep
6,534
def open_files(by_pid=False): ''' Return a list of all physical open files on the system. CLI Examples: .. code-block:: bash salt '*' file.open_files salt '*' file.open_files by_pid=True ''' # First we collect valid PIDs pids = {} procfs = os.listdir('/proc/') for ...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/open_files
6,535
def move(src, dst): ''' Move a file or directory CLI Example: .. code-block:: bash salt '*' file.move /path/to/src /path/to/dst ''' src = os.path.expanduser(src) dst = os.path.expanduser(dst) if not os.path.isabs(src): raise SaltInvocationError('Source path must be ab...
IOError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/move
6,536
def diskusage(path): ''' Recursively calculate disk usage of path and return it in bytes CLI Example: .. code-block:: bash salt '*' file.diskusage /path/to/check ''' total_size = 0 seen = set() if os.path.isfile(path): stat_structure = os.stat(path) ret = ...
OSError
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/diskusage
6,537
def _get_db_settings(self): """Create DB settings according to the configuration file.""" config_path = os.path.expanduser( self.config.FrameworkConfigGet('DATABASE_SETTINGS_FILE')) settings = {} with FileOperations.open(config_path, 'r') as f: for line in f: ...
ValueError
dataset/ETHPy150Open owtf/owtf/framework/db/db.py/DB._get_db_settings
6,538
def CreateEngine(self, BaseClass): try: engine = create_engine( "postgresql+psycopg2://{0}:{1}@{2}:{3}/{4}".format( self._db_settings['DATABASE_USER'], self._db_settings['DATABASE_PASS'], self._db_settings['DATABASE_IP'], ...
ValueError
dataset/ETHPy150Open owtf/owtf/framework/db/db.py/DB.CreateEngine
6,539
@packageCallback def packageCallback_importControllers(packagename): try: __import__('{}._webapp'.format(packagename)) except __HOLE__, e: print "packageCallback_importControllers", packagename, e #raise pass
ImportError
dataset/ETHPy150Open elistevens/solari/wsgi/solariwsgi/core.py/packageCallback_importControllers
6,540
def _get_servers(self, req, is_detail): """Returns a list of servers, based on any search options specified.""" search_opts = {} search_opts.update(req.GET) context = req.environ['nova.context'] remove_invalid_options(context, search_opts, self._get_server_searc...
ValueError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._get_servers
6,541
def _get_injected_files(self, personality): """Create a list of injected files from the personality attribute. At this time, injected_files must be formatted as a list of (file_path, file_content) pairs for compatibility with the underlying compute service. """ injected_...
TypeError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._get_injected_files
6,542
def _get_requested_networks(self, requested_networks): """Create a list of requested networks from the networks attribute.""" networks = [] network_uuids = [] for network in requested_networks: request = objects.NetworkRequest() try: try: ...
TypeError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._get_requested_networks
6,543
def _decode_base64(self, data): if isinstance(data, six.binary_type) and hasattr(data, "decode"): try: data = data.decode("utf-8") except __HOLE__: return None data = re.sub(r'\s', '', data) if not self.B64_REGEX.match(data): re...
UnicodeDecodeError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._decode_base64
6,544
@wsgi.response(202) def create(self, req, body): """Creates a new server for a given user.""" if not self.is_valid_body(body, 'server'): raise exc.HTTPUnprocessableEntity() context = req.environ['nova.context'] server_dict = body['server'] password = self._get_se...
UnicodeDecodeError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller.create
6,545
def _image_ref_from_req_data(self, data): try: return six.text_type(data['server']['imageRef']) except (__HOLE__, KeyError): msg = _("Missing imageRef attribute") raise exc.HTTPBadRequest(explanation=msg)
TypeError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._image_ref_from_req_data
6,546
def _flavor_id_from_req_data(self, data): try: flavor_ref = data['server']['flavorRef'] except (__HOLE__, KeyError): msg = _("Missing flavorRef attribute") raise exc.HTTPBadRequest(explanation=msg) try: return common.get_id_from_href(flavor_ref) ...
TypeError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._flavor_id_from_req_data
6,547
@wsgi.response(202) @wsgi.action('changePassword') def _action_change_password(self, req, id, body): context = req.environ['nova.context'] if (not body.get('changePassword') or 'adminPass' not in body['changePassword']): msg = _("No adminPass was specified") ...
NotImplementedError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._action_change_password
6,548
def _validate_metadata(self, metadata): """Ensure that we can work with the metadata given.""" try: six.iteritems(metadata) except __HOLE__: msg = _("Unable to parse metadata key/value pairs.") LOG.debug(msg) raise exc.HTTPBadRequest(explanation=ms...
AttributeError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._validate_metadata
6,549
@wsgi.response(202) @wsgi.action('resize') def _action_resize(self, req, id, body): """Resizes a given instance to the flavor size requested.""" try: flavor_ref = str(body["resize"]["flavorRef"]) if not flavor_ref: msg = _("Resize request has invalid 'flav...
KeyError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._action_resize
6,550
@wsgi.response(202) @wsgi.action('rebuild') def _action_rebuild(self, req, id, body): """Rebuild an instance with the given attributes.""" body = body['rebuild'] try: image_href = body["imageRef"] except (KeyError, TypeError): msg = _("Could not parse ima...
TypeError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._action_rebuild
6,551
@wsgi.response(202) @wsgi.action('createImage') @common.check_snapshots_enabled def _action_create_image(self, req, id, body): """Snapshot a server instance.""" context = req.environ['nova.context'] entity = body.get("createImage", {}) image_name = entity.get("name") ...
ValueError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._action_create_image
6,552
def _get_server_admin_password(self, server): """Determine the admin password for a server on creation.""" try: password = server['adminPass'] self._validate_admin_password(password) except __HOLE__: password = utils.generate_password() except ValueErr...
KeyError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/servers.py/Controller._get_server_admin_password
6,553
def getSession(self, sessionInterface = None): # Session management if not self.session: cookiename = string.join(['TWISTED_SESSION'] + self.sitepath, "_") sessionCookie = self.getCookie(cookiename) if sessionCookie: try: self.sessi...
KeyError
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/web/server.py/Request.getSession
6,554
def test_transientlogger(): import random, time happy, nightmare = luv(), bad_things() try: while True: if random.randrange(60) == 0: logger.warning(nightmare.next()) else: logger.debug(happy.next()) time.sleep(0.02) except __HO...
StopIteration
dataset/ETHPy150Open jart/fabulous/fabulous/test_transientlogging.py/test_transientlogger
6,555
def test_transientlogger2(): import time, random gothic = lorem_gotham() try: while True: if random.randrange(20) == 0: logger.warning(red(gothic.next())) else: logger.debug(gothic.next()) time.sleep(0.1) except __HOLE__: ...
StopIteration
dataset/ETHPy150Open jart/fabulous/fabulous/test_transientlogging.py/test_transientlogger2
6,556
def installed( name, version=None, refresh=None, fromrepo=None, skip_verify=False, skip_suggestions=False, pkgs=None, sources=None, allow_updates=False, pkg_verify=False, normalize=True, ignore_epoch=False, reinstall...
ValueError
dataset/ETHPy150Open saltstack/salt/salt/states/pkg.py/installed
6,557
def testViewSignatures(self): for app_name in settings.INSTALLED_APPS: try: views = import_module(app_name+'.views') except __HOLE__: continue for view_name in dir(views): view = getattr(views, view_name) if n...
ImportError
dataset/ETHPy150Open mollyproject/mollyproject/molly/apps/search/tests.py/GenericSearchTestCase.testViewSignatures
6,558
def parse_timestamp(s): ''' Returns (datetime, tz offset in minutes) or (None, None). ''' m = re.match(""" ^ (?P<year>-?[0-9]{4}) - (?P<month>[0-9]{2}) - (?P<day>[0-9]{2}) T (?P<hour>[0-9]{2}) : (?P<minute>[0-9]{2}) : (?P<second>[0-9]{2}) (?P<microsecond>\.[0-9]{1,6})? (?P<tz> Z | (?P<tz_hr>[-+][0-9]{2}) : (?P...
ValueError
dataset/ETHPy150Open Esri/solutions-geoprocessing-toolbox/data_management/toolboxes/scripts/ImportPatrolRptXML.py/parse_timestamp
6,559
def _open_write(self): try: backend.SaveFile(self.name, '') except __HOLE__ as e: self._closed = True raise e
IOError
dataset/ETHPy150Open mockfs/mockfs/mockfs/storage.py/file._open_write
6,560
def provision_persistent_stores(self, app_names, options): """ Provision all persistent stores for all apps or for only the app name given. """ # Set refresh parameter database_refresh = options['refresh'] # Get the app harvester app_harvester = SingletonAppHarve...
ImportError
dataset/ETHPy150Open tethysplatform/tethys/tethys_apps/management/commands/syncstores.py/Command.provision_persistent_stores
6,561
def is_waiting_to_run(self): if self.status != self.WAITING: LOG.info("Migration: {} has already run!".format(self)) return False inspect = control.inspect() scheduled_tasks = inspect.scheduled() try: hosts = scheduled_tasks.keys() except Exce...
TypeError
dataset/ETHPy150Open globocom/database-as-a-service/dbaas/region_migration/models.py/DatabaseRegionMigrationDetail.is_waiting_to_run
6,562
def run(self): from docutils.core import publish_cmdline from docutils.nodes import raw from docutils.parsers import rst from genshi.input import HTMLParser from genshi.template import TemplateLoader docutils_conf = os.path.join(TOOLS_DIR, 'conf', 'docutils.ini') ...
ImportError
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Babel-0.9.6/doc/common/doctools.py/build_doc.run
6,563
def get_theme(self, matcher_info): if not matcher_info or matcher_info not in self.local_themes: return self.theme match = self.local_themes[matcher_info] try: return match['theme'] except __HOLE__: match['theme'] = Theme( theme_config=match['config'], main_theme_config=self.theme_config, ...
KeyError
dataset/ETHPy150Open powerline/powerline/powerline/renderers/lemonbar.py/LemonbarRenderer.get_theme
6,564
def run(self): # We cannot use os.waitpid because it works only for child processes. from errno import EINTR while True: try: if os.getppid() == 1: os._exit(1) time.sleep(1.0) except __HOLE__ as e: if e.e...
OSError
dataset/ETHPy150Open ipython/ipython-py3k/IPython/zmq/parentpoller.py/ParentPollerUnix.run
6,565
def __getattr__(self, name): frame = self._storage while frame: try: return getattr(frame, name) except __HOLE__: frame = frame._parent_storage #raise AttributeError(name) raise AttributeError("{} has no attribute {}".format( ...
AttributeError
dataset/ETHPy150Open SmartTeleMax/iktomi/iktomi/utils/storage.py/VersionedStorage.__getattr__
6,566
def init(names, host=None, saltcloud_mode=False, quiet=False, **kwargs): ''' Initialize a new container .. code-block:: bash salt-run lxc.init name host=minion_id [cpuset=cgroups_cpuset] \\ [cpushare=cgroups_cpushare] [memory=cgroups_memory] \\ [template=lxc_templa...
TypeError
dataset/ETHPy150Open saltstack/salt/salt/runners/lxc.py/init
6,567
def get_filename_variant(file_name, resource_suffix_map): # Given a filename # Get a list of variant IDs, and the root file name file_name_parts = os.path.splitext(file_name) if file_name_parts[0] == '~': raise Exception('Cannot start a file name with a ~ character') split = file_name_parts[...
KeyError
dataset/ETHPy150Open pebble/cloudpebble/ide/tasks/archive.py/get_filename_variant
6,568
@task(acks_late=True) def do_import_archive(project_id, archive, delete_project=False): project = Project.objects.get(pk=project_id) try: with tempfile.NamedTemporaryFile(suffix='.zip') as archive_file: archive_file.write(archive) archive_file.flush() with zipfile.Zip...
KeyError
dataset/ETHPy150Open pebble/cloudpebble/ide/tasks/archive.py/do_import_archive
6,569
def _parseLabelSpec(label_spec): if not ':' in label_spec: raise error.TopologyError('Invalid label description: %s' % label_spec) label_type_alias, label_range = label_spec.split(':', 1) try: label_type = LABEL_TYPES[label_type_alias] except __HOLE__: raise error.TopologyError...
KeyError
dataset/ETHPy150Open NORDUnet/opennsa/opennsa/topology/nrm.py/_parseLabelSpec
6,570
def parsePortSpec(source): # Parse the entries like the following: ## type name remote label bandwidth interface authorization # #ethernet ps - vlan:1780-1783 1000 em0 user=user@exam...
ValueError
dataset/ETHPy150Open NORDUnet/opennsa/opennsa/topology/nrm.py/parsePortSpec
6,571
def __call__(self, doc, context=None): items = _evaluate_items_expression(self._items_expression, doc, context) # all items should be iterable, if not return empty list for item in items: if not isinstance(item, list): return [] try: return(list(i...
TypeError
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/userreports/expressions/list_specs.py/FlattenExpressionSpec.__call__
6,572
def __call__(self, doc, context=None): items = _evaluate_items_expression(self._items_expression, doc, context) try: return sorted( items, key=lambda i: self._sort_expression(i, context), reverse=True if self.order == self.DESC else False ...
TypeError
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/userreports/expressions/list_specs.py/SortItemsExpressionSpec.__call__
6,573
def validate_int_range(parsed_args, attr_name, min_value=None, max_value=None): val = getattr(parsed_args, attr_name, None) if val is None: return try: if not isinstance(val, int): int_val = int(val, 0) else: int_val = val if ((min_value is None or min...
TypeError
dataset/ETHPy150Open openstack/python-neutronclient/neutronclient/common/validators.py/validate_int_range
6,574
def validate_ip_subnet(parsed_args, attr_name): val = getattr(parsed_args, attr_name) if not val: return try: netaddr.IPNetwork(val) except (netaddr.AddrFormatError, __HOLE__): raise exceptions.CommandError( (_('%(attr_name)s "%(val)s" is not a valid CIDR.') % ...
ValueError
dataset/ETHPy150Open openstack/python-neutronclient/neutronclient/common/validators.py/validate_ip_subnet
6,575
def OnData(self, x, y, default_drag_result): """ Called when OnDrop returns True. """ # First, if we have a source in the clipboard and the source # doesn't allow moves then change the default to copy if clipboard.drop_source is not None and \ not clipboard.drop_source.allow_...
ImportError
dataset/ETHPy150Open enthought/pyface/pyface/wx/drag_and_drop.py/PythonDropTarget.OnData
6,576
def test_no_state_var_err(self): try: self.prob.setup(check=False) except __HOLE__ as err: self.assertEqual(str(err), "'state_var' option in Brent solver of root must be specified") else: self.fail('ValueError Expected')
ValueError
dataset/ETHPy150Open OpenMDAO/OpenMDAO/openmdao/solvers/test/test_brent_solver.py/TestBrentSolver.test_no_state_var_err
6,577
def test_data_pass_bounds(self): p = Problem() p.root = Group() p.root.add('lower', ExecComp('low = 2*a'), promotes=['low', 'a']) p.root.add('upper', ExecComp('high = 2*b'), promotes=['high', 'b']) sub = p.root.add('sub', Group(), promotes=['x','low', 'high']) sub.add(...
ValueError
dataset/ETHPy150Open OpenMDAO/OpenMDAO/openmdao/solvers/test/test_brent_solver.py/TestBrentSolver.test_data_pass_bounds
6,578
def is_valid_javascript_identifier(identifier, escape=r'\u', ucd_cat=category): """Return whether the given ``id`` is a valid Javascript identifier.""" if not identifier: return False if not isinstance(identifier, unicode): try: identifier = unicode(identifier, 'utf-8') ...
UnicodeDecodeError
dataset/ETHPy150Open dgraziotin/dycapo/piston/validate_jsonp.py/is_valid_javascript_identifier
6,579
def Node(*args): kind = args[0] if nodes.has_key(kind): try: return nodes[kind](*args[1:]) except __HOLE__: print nodes[kind], len(args), args raise else: raise WalkerError, "Can't find appropriate Node type: %s" % str(args) #return apply(a...
TypeError
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/compiler/transformer.py/Node
6,580
def __deepcopy__(self, memo): """Method used by copy.deepcopy(). This also uses the state_pickler to work correctly. """ # Create a new instance. new = self.__class__() # If we have a saved state, use it for the new instance. If # not, get our state and save tha...
IndexError
dataset/ETHPy150Open enthought/mayavi/mayavi/core/base.py/Base.__deepcopy__
6,581
def _load_view_non_cached(self, name, view_element): """ Loads the view by execing a file. Useful when tweaking views. """ result = {} view_filename = self._view_filename try: exec(compile( open(view_filename).read(), view_filename, 'exec')...
IOError
dataset/ETHPy150Open enthought/mayavi/mayavi/core/base.py/Base._load_view_non_cached
6,582
def run(): setup_logger() logger.info('Started') event_handler = EventHandler() observer = Observer(timeout=0.1) observer.event_queue.maxsize = EVENT_QUEUE_MAX_SIZE try: delete_all_files(FRAMES_PATH) observer.schedule(event_handler, path=FRAMES_PATH, recursive=True) obser...
KeyboardInterrupt
dataset/ETHPy150Open jbochi/live_thumb/broadcaster.py/run
6,583
def get(self, service_id, bay_ident): try: return self._list(self._path(service_id, bay_ident))[0] except __HOLE__: return None
IndexError
dataset/ETHPy150Open openstack/python-magnumclient/magnumclient/v1/services.py/ServiceManager.get
6,584
def parse(self, ofx): try: for line in ofx.splitlines(): if line.strip() == "": break header, value = line.split(":") self.headers[header] = value except __HOLE__: pass except: raise f...
ValueError
dataset/ETHPy150Open jseutter/ofxparse/ofxparse/ofxutil.py/OfxUtil.parse
6,585
def start_config_thread(self, filename, section=None, refresh_config_seconds=10): """ Start a daemon thread to reload the given config file and section periodically. Load the config once before returning. This function must be called at most once. """ assert not self._lo...
IOError
dataset/ETHPy150Open dropbox/grouper/grouper/settings.py/Settings.start_config_thread
6,586
def __getattr__(self, name): with self.lock: try: return self.settings[name] except __HOLE__ as err: raise AttributeError(err)
KeyError
dataset/ETHPy150Open dropbox/grouper/grouper/settings.py/Settings.__getattr__
6,587
def domains_to_metadata(domains): '''Construct a metadata dict out of the domains dict. The domains dict has the following form: keys: variable names from a factor graph vals: list of possible values the variable can have The metadata dict has the following form: keys: (same as above) ...
KeyError
dataset/ETHPy150Open eBay/bayesian-belief-networks/bayesian/persistance.py/domains_to_metadata
6,588
def build_row_factory(conn): ''' Introspect the samples table to build the row_factory function. We will assume that numeric values are Boolean and all other values are Strings. Should we encounter a numeric value not in (0, 1) we will raise an error. ''' cur = conn.cursor() ...
KeyError
dataset/ETHPy150Open eBay/bayesian-belief-networks/bayesian/persistance.py/build_row_factory
6,589
@classmethod def resolve_contents(cls, contents, env): """Resolve bundle names.""" result = [] for f in contents: try: result.append(env[f]) except __HOLE__: result.append(f) return result
KeyError
dataset/ETHPy150Open miracle2k/webassets/src/webassets/ext/jinja2.py/AssetsExtension.resolve_contents
6,590
def main(argv=None): parser = E.OptionParser( version="%prog version: $Id: quality2masks.py 2781 2009-09-10 11:33:14Z andreas $", usage=globals()["__doc__"]) parser.add_option("--quality-threshold", dest="quality_threshold", type="int", help="quality threshold for masking positio...
ValueError
dataset/ETHPy150Open CGATOxford/cgat/scripts/quality2masks.py/main
6,591
def test_works_with_unconfigured_configuration(self): try: # reset class level attributes on Configuration set in test helper imp.reload(braintree.configuration) config = Configuration( environment=braintree.Environment.Sandbox, merchant_id='my...
AttributeError
dataset/ETHPy150Open braintree/braintree_python/tests/unit/test_configuration.py/TestConfiguration.test_works_with_unconfigured_configuration
6,592
def shrink_case(case): toks = case.split("-") def shrink_if_number(x): try: cvt = int(x) return str(cvt) except __HOLE__: return x return "-".join([shrink_if_number(t) for t in toks])
ValueError
dataset/ETHPy150Open woshialex/diagnose-heart/CNN_A/preprocess.py/shrink_case
6,593
def publish_display_data(data, source='bokeh'): ''' Compatibility wrapper for IPython ``publish_display_data`` Later versions of IPython remove the ``source`` (first) argument. This function insulates Bokeh library code from this change. Args: source (str, optional) : the source arg for IPytho...
TypeError
dataset/ETHPy150Open bokeh/bokeh/bokeh/util/notebook.py/publish_display_data
6,594
def api_request(host, url, data=None, method=None): if data: method = method or 'POST' else: method = method or 'GET' if ssl is False: msg.warn('Error importing ssl. Using system python...') return proxy_api_request(host, url, data, method) try: r = hit_url(host, ...
HTTPError
dataset/ETHPy150Open Floobits/floobits-vim/plugin/floo/common/api.py/api_request
6,595
def get_mysql_credentials(cfg_file): """Get the credentials and database name from options in config file.""" try: parser = ConfigParser.ConfigParser() cfg_fp = open(cfg_file) parser.readfp(cfg_fp) cfg_fp.close() except ConfigParser.NoOptionError: cfg_fp.close() ...
ValueError
dataset/ETHPy150Open openstack/networking-cisco/tools/saf_prepare_setup.py/get_mysql_credentials
6,596
def modify_conf(cfgfile, service_name, outfn): """Modify config file neutron and keystone to include enabler options.""" if not cfgfile or not outfn: print('ERROR: There is no config file.') sys.exit(0) options = service_options[service_name] with open(cfgfile, 'r') as cf: line...
ValueError
dataset/ETHPy150Open openstack/networking-cisco/tools/saf_prepare_setup.py/modify_conf
6,597
def Cleanup(self, vm): """Clean up RDS instances, cleanup the extra subnet created for the creation of the RDS instance. Args: vm: The VM that was used as the test client, which also stores states for clean-up. """ # Now, we can delete the DB instance. vm.db_instance_id is the i...
ValueError
dataset/ETHPy150Open GoogleCloudPlatform/PerfKitBenchmarker/perfkitbenchmarker/linux_benchmarks/mysql_service_benchmark.py/RDSMySQLBenchmark.Cleanup
6,598
def loadfile(self, filename): try: # open the file in binary mode so that we can handle # end-of-line convention ourselves. with open(filename, 'rb') as f: chars = f.read() except __HOLE__ as msg: tkMessageBox.showerror("I/O Error", str(m...
IOError
dataset/ETHPy150Open francelabs/datafari/windows/python/Lib/idlelib/IOBinding.py/IOBinding.loadfile
6,599
def save(self, event): if not self.filename: self.save_as(event) else: if self.writefile(self.filename): self.set_saved(True) try: self.editwin.store_file_breaks() except __HOLE__: # may be a PyShell ...
AttributeError
dataset/ETHPy150Open francelabs/datafari/windows/python/Lib/idlelib/IOBinding.py/IOBinding.save