Get all media from MEDIA_ROOT
547780
def get_all_media(exclude=None):
    

    if not exclude:
        exclude = []

    media = set()

    for root, dirs, files in os.walk(six.text_type(settings.MEDIA_ROOT)):
        for name in files:
            path = os.path.abspath(os.path.join(root, name))
            relpath = os.path.relpath(path, settings.MEDIA_ROOT)
            for e in exclude:
                if re.match(r'^%s$' % re.escape(e).replace('\\*', '.*'), relpath):
                    break
            else:
                media.add(path)

    return media
347917
def get_media(self, v14_scriptable):
        """"""
        images = []
        sounds = []
        for media in v14_scriptable.media:
            if media.class_name == 'SoundMedia':
                sounds.append(media)
            elif media.class_name == 'ImageMedia':
                images.append(media)
        return (images, sounds)
246049
async def get_contents(self, uri) -> List[Content]:
        
        contents = [
            Content.make(**x)
            for x in await self.services["avContent"]["getContentList"](uri=uri)
        ]
        contentlist = []

        for content in contents:
            if content.contentKind == "directory" and content.index >= 0:
                # print("got directory %s" % content.uri)
                res = await self.get_contents(content.uri)
                contentlist.extend(res)
            else:
                contentlist.append(content)
                # print("%s%s" % (' ' * depth, content))
        return contentlist
574317
def _root(name='', all_roots=False):
    '''
    
    '''
    if _sd_version() >= 219:
        if all_roots:
            return [os.path.join(x, name)
                    for x in ('/var/lib/machines', '/var/lib/container')]
        else:
            return os.path.join('/var/lib/machines', name)
    else:
        ret = os.path.join('/var/lib/container', name)
        if all_roots:
            return [ret]
        else:
            return ret
846960
def get_all_hosts(resource_root, view=None):
  
  return call(resource_root.get, HOSTS_PATH, ApiHost, True,
          params=view and dict(view=view) or None)
1079992
def _remove_media(self,directory,files=None):
        """"""
        # Connect if we aren't already
        if not self._connectToFlickr():
            logger.error("%s - Couldn't connect to flickr")
            return False

        db=self._loadDB(directory)
        # If no files given, use files from DB in dir
        if not files:
            files=db.keys()

        #If only one file given, make it a list
        if isinstance(files,basestring):
            files=[files]

        for fn in files:
            print("%s - Deleting from flickr [local copy intact]"%(fn))

            try:
                pid=db[fn]['photoid']
            except:
                logger.debug("%s - Was never in flickr DB"%(fn))
                continue
            resp=self.flickr.photos_delete(photo_id=pid,format='etree')
            if resp.attrib['stat']!='ok':
                print("%s - flickr: delete failed with status: %s",\
                        resp.attrib['stat']);
                return False
            else:
                logger.debug('Removing %s from flickr DB'%(fn))
                del db[fn]
                self._saveDB(directory,db)

        return True
550802
def find_all(root, path):
  """"""
  path = parse_path(path)

  if len(path) == 1:
    yield from get_children(root, path[0])
  else:
    for child in get_children(root, path[0]):
      yield from find_all(child, path[1:])
261982
public function getAll(Request $request)
    {
        $this->authorize(MediasPolicy::PERMISSION_LIST);

        return $this->jsonResponseSuccess([
            'medias' => $this->media->all(
                $request->get('location', '/')
            ),
        ]);
    }
1217444
def libvlc_media_get_user_data(p_md):
    '''
    '''
    f = _Cfunctions.get('libvlc_media_get_user_data', None) or \
        _Cfunction('libvlc_media_get_user_data', ((1,),), None,
                    ctypes.c_void_p, Media)
    return f(p_md)
1305180
private static function getMediaRootRelative() {
    $config = ObjectFactory::getInstance('configuration');
    $mediaRootAbs = $config->getDirectoryValue('uploadDir', 'Media');
    return self::makeRelative($mediaRootAbs);
  }
1045045
def list(self, device_path, timeout_ms=None):
    """"""
    return self.filesync_service.list(
        device_path, timeouts.PolledTimeout.from_millis(timeout_ms))
341964
private function getMediasPermissions()
    {
        return [
            [
                'name'        => 'Medias - List all medias',
                'description' => 'Allow to list all the medias.',
                'slug'        => MediasPolicy::PERMISSION_LIST,
            ],
            [
                'name'        => 'Medias - View a media',
                'description' => 'Allow to display a media.',
                'slug'        => MediasPolicy::PERMISSION_SHOW,
            ],
            [
                'name'        => 'Medias - Download a media',
                'description' => 'Allow to download a media.',
                'slug'        => MediasPolicy::PERMISSION_CREATE,
            ],
            [
                'name'        => 'Medias - Update a media',
                'description' => 'Allow to update a media.',
                'slug'        => MediasPolicy::PERMISSION_UPDATE,
            ],
            [
                'name'        => 'Medias - Delete a media',
                'description' => 'Allow to delete a media.',
                'slug'        => MediasPolicy::PERMISSION_DELETE,
            ],
        ];
    }
778726
def load_media(self, max_pages=150):
        
        logger.info("loading media")

        # clear them all out so we don't get dupes
        if self.purge_first:
            logger.warning("purging ALL media from site %s", self.site_id)
            Media.objects.filter(site_id=self.site_id).delete()

        path = "sites/{}/media".format(self.site_id)
        params = {"number": 100}
        self.set_media_params_after(params)
        page = 1

        response = self.get(path, params)

        if not response.ok:
            logger.warning("Response NOT OK! status_code=%s\n%s", response.status_code, response.text)

        while response.ok and response.text and page < max_pages:
            logger.info(" - page: %d", page)

            api_medias = response.json().get("media")
            if not api_medias:
                # we're done here
                break

            medias = []
            for api_media in api_medias:

                # exclude media items that are not attached to posts (for now)
                if api_media["post_ID"] != 0:

                    # if it exists locally, update local version if anything has changed
                    existing_media = Media.objects.filter(site_id=self.site_id, wp_id=api_media["ID"]).first()
                    if existing_media:
                        self.update_existing_media(existing_media, api_media)
                    else:
                        medias.append(self.get_new_media(api_media))

            if medias:
                Media.objects.bulk_create(medias)

            # get next page
            page += 1
            params["page"] = page
            response = self.get(path, params)

            if not response.ok:
                logger.warning("Response NOT OK! status_code=%s\n%s", response.status_code, response.text)
                return
1304937
def get_media_requests(self, item, info):
        
        key_generator = item.get(self.QINIU_KEY_GENERATOR_FIELD)
        return [Request(x, meta={'qiniu_key_generator': key_generator}) for x in item.get(self.FILES_URLS_FIELD, [])]
600557
def get_media(media_uri)
      get_resource(media_uri)
      if @rc.instance_of?(Atom::Entry)
        raise ResponseError, "Response is not Media Resource"
      end
      return @rc, @res.content_type
    end
689751
private static void getFilesByExtensionRecursive(Collection<Media> filesList, Media path, String extension)
    {
        for (final Media content : path.getMedias())
        {
            if (extension.equals(UtilFile.getExtension(content.getPath())))
            {
                filesList.add(content);
            }
        }
    }
1306572
def get_all_handleable_roots(self):
        
        nodes = self.get_device_tree()
        return [node.device
                for node in sorted(nodes.values(), key=DevNode._sort_key)
                if not node.ignored and node.device
                and (node.root == '/' or nodes[node.root].ignored)]