Make a note that we tried to get the zonefile from storage
321305
def atlasdb_set_zonefile_tried_storage( zonefile_hash, tried_storage, con=None, path=None ):
    
    with AtlasDBOpen(con=con, path=path) as dbcon:
        if tried_storage:
            tried_storage = 1
        else:
            tried_storage = 0

        sql = "UPDATE zonefiles SET tried_storage = ? WHERE zonefile_hash = ?;"
        args = (tried_storage, zonefile_hash)

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )
        dbcon.commit()

    return True
142115
def getabsfile(object):
    """"""
    return os.path.normcase(
        os.path.abspath(getsourcefile(object) or getfile(object)))
453909
@Nullable
  private File getCachedFile(String url) throws FileNotFoundException {
    File jsonFile = new File(appContext.getCacheDir(), filenameForUrl(url, FileExtension.JSON, false));
    if (jsonFile.exists()) {
      return jsonFile;
    }
    File zipFile = new File(appContext.getCacheDir(), filenameForUrl(url, FileExtension.ZIP, false));
    if (zipFile.exists()) {
      return zipFile;
    }
    return null;
  }
880509
def _load_local_tzinfo():
  """"""
  tzdir = os.environ.get("TZDIR", "/usr/share/zoneinfo/posix")

  localtzdata = {}
  for dirpath, _, filenames in os.walk(tzdir):
    for filename in filenames:
      filepath = os.path.join(dirpath, filename)
      name = os.path.relpath(filepath, tzdir)

      f = open(filepath, "rb")
      tzinfo = pytz.tzfile.build_tzinfo(name, f)
      f.close()
      localtzdata[name] = tzinfo

  return localtzdata
503399
def getoutputfile(self, loadmetadata=True, client=None,requiremetadata=False):
        """"""
        return next(self.getoutputfiles(loadmetadata,client,requiremetadata))
1346297
def _get_cached_file_name(bucket_name, saltenv, path):
    '''
    
    '''

    file_path = os.path.join(_get_cache_dir(), saltenv, bucket_name, path)

    # make sure bucket and saltenv directories exist
    if not os.path.exists(os.path.dirname(file_path)):
        os.makedirs(os.path.dirname(file_path))

    return file_path
692853
def atlasdb_reset_zonefile_tried_storage( con=None, path=None ):
    

    with AtlasDBOpen(con=con, path=path) as dbcon:

        sql = "UPDATE zonefiles SET tried_storage = ? WHERE present = ?;"
        args = (0, 0)

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )
        dbcon.commit()

    return True
106160
def atlas_zonefile_push_enqueue( zonefile_hash, name, txid, zonefile_data, zonefile_queue=None, con=None, path=None ):
    
    res = False

    bits = atlasdb_get_zonefile_bits( zonefile_hash, path=path, con=con )
    if len(bits) == 0:
        # invalid hash
        return

    with AtlasZonefileQueueLocked(zonefile_queue) as zfq:

        if len(zfq) < MAX_QUEUED_ZONEFILES: 
            zfdata = {
                'zonefile_hash': zonefile_hash,
                'zonefile': zonefile_data,
                'name': name,
                'txid': txid
            }

            zfq.append( zfdata )
            res = True
    
    return res
1075133
def _check_if_downloaded(self):
        
        if not os.path.isfile(self.path + self.file_name):
            print("")
            self.msg.template(78)
            print("| Download '{0}' file [ {1}FAILED{2} ]".format(
                self.file_name, self.meta.color["RED"],
                self.meta.color["ENDC"]))
            self.msg.template(78)
            print("")
            if not self.msg.answer() in ["y", "Y"]:
                raise SystemExit()
1104600
function (storeOrEditor, from, to) {
    debug('Performing inMemoryCopy from ' + from + ' to ' + to + '.');
    var fromLen = from.length;
    this.processInMemoryStore(storeOrEditor, (file, store) => {
      var idx = file.path.indexOf(from);
      if (idx === 0 && file.contents !== null && file.state !== 'deleted') {
        var absTo = path.join(to, file.path.substr(fromLen));
        // exact match so we are copying a single file and not a folder
        if (fromLen === file.path.length) {
          absTo = path.join(to, path.basename(file.path));
        }
        debug('CREATING COPY IN-MEMORY: ' + absTo);
        var newFile = store.get(absTo);
        newFile.contents = file.contents;
        newFile.state = 'modified';
        store.add(newFile);
      }
    });
  }
731268
def resume(localfile, jottafile, JFS):
    """"""
    with open(localfile) as lf:
        _complete = jottafile.resume(lf)
    return _complete
360174
def _get_zone_name(self):
        """"""
        if self._name is None:
            # Collect tags for AppCommand.xml call
            tags = ["GetZoneName"]
            # Execute call
            root = self.exec_appcommand_post(tags)
            # Check result
            if root is None:
                _LOGGER.error("Getting ZoneName failed.")
            else:
                zone = self._get_own_zone()

                try:
                    name = root.find(
                        "./cmd/{zone}".format(zone=zone)).text
                except AttributeError:
                    _LOGGER.error("No ZoneName found for zone %s", self.zone)
                else:
                    self._name = name.strip()
206711
function (storeOrEditor, from, to) {
    debug('Performing inMemoryMove from ' + from + ' to ' + to);
    var store = (storeOrEditor && storeOrEditor.store ? storeOrEditor.store : storeOrEditor);
    var memFsEditor = require('mem-fs-editor').create(store);
    var fromLen = from.length;
    store.each(function (file) {
      var idx = file.path.indexOf(from);
      if (idx === 0 && file.contents !== null && file.state !== 'deleted') {
        var absTo = path.join(to, file.path.substr(fromLen));
        // exact match so we are copying a single file and not a folder
        if (fromLen === file.path.length) {
          absTo = path.join(to, path.basename(file.path));
        }
        debug('IN-MEMORY MOVING FROM: ' + file.path + ' TO: ' + absTo);
        memFsEditor.move(file.path, absTo);
      }
    });
  }
495271
def dump_zone_file(self):
        
        data = []
        for zone in sorted(self, key=attrgetter('country')):
            text = ['%s	%s	%s'
                    % (zone.country,
                       utils.to_iso6709(zone.latitude, zone.longitude,
                                        format='dms')[:-1],
                       zone.zone), ]
            if zone.comments:
                text.append('	%s' % ', '.join(zone.comments))
            data.append(''.join(text))
        return data
270945
def do_AtomicWriteFileRequest(self, apdu):
        """"""
        if _debug: FileServices._debug("do_AtomicWriteFileRequest %r", apdu)

        if (apdu.fileIdentifier[0] != 'file'):
            raise ExecutionError('services', 'inconsistentObjectType')

        # get the object
        obj = self.get_object_id(apdu.fileIdentifier)
        if _debug: FileServices._debug("    - object: %r", obj)

        if not obj:
            raise ExecutionError('object', 'unknownObject')

        if apdu.accessMethod.recordAccess:
            # check against the object
            if obj.fileAccessMethod != 'recordAccess':
                raise ExecutionError('services', 'invalidFileAccessMethod')

            # simplify
            record_access = apdu.accessMethod.recordAccess

            # check for required parameters
            if record_access.fileStartRecord is None:
                raise MissingRequiredParameter("fileStartRecord required")
            if record_access.recordCount is None:
                raise MissingRequiredParameter("recordCount required")
            if record_access.fileRecordData is None:
                raise MissingRequiredParameter("fileRecordData required")

            # check for read-only
            if obj.readOnly:
                raise ExecutionError('services', 'fileAccessDenied')

            # pass along to the object
            start_record = obj.write_record(
                record_access.fileStartRecord,
                record_access.recordCount,
                record_access.fileRecordData,
                )
            if _debug: FileServices._debug("    - start_record: %r", start_record)

            # this is an ack
            resp = AtomicWriteFileACK(context=apdu,
                fileStartRecord=start_record,
                )

        elif apdu.accessMethod.streamAccess:
            # check against the object
            if obj.fileAccessMethod != 'streamAccess':
                raise ExecutionError('services', 'invalidFileAccessMethod')

            # simplify
            stream_access = apdu.accessMethod.streamAccess

            # check for required parameters
            if stream_access.fileStartPosition is None:
                raise MissingRequiredParameter("fileStartPosition required")
            if stream_access.fileData is None:
                raise MissingRequiredParameter("fileData required")

            # check for read-only
            if obj.readOnly:
                raise ExecutionError('services', 'fileAccessDenied')

            # pass along to the object
            start_position = obj.write_stream(
                stream_access.fileStartPosition,
                stream_access.fileData,
                )
            if _debug: FileServices._debug("    - start_position: %r", start_position)

            # this is an ack
            resp = AtomicWriteFileACK(context=apdu,
                fileStartPosition=start_position,
                )

        if _debug: FileServices._debug("    - resp: %r", resp)

        # return the result
        self.response(resp)
940438
def Get(self):
    """"""

    args = vfs_pb2.ApiGetFileDetailsArgs(
        client_id=self.client_id, file_path=self.path)
    data = self._context.SendRequest("GetFileDetails", args).file
    return File(client_id=self.client_id, data=data, context=self._context)
197034
def _tmpfile(self, cache_key, use):
    """"""
    with temporary_file(suffix=cache_key.id + use, root_dir=self._cache_root,
                        permissions=self._permissions) as tmpfile:
      yield tmpfile