Esempio n. 1
0
    def take_action(self, args):
        import os
        import requests
        import tempfile
        import fabulous.image

        result = api.search(
            args.package,
            rows_per_page=1,
            start_row=0,
        )

        if not result['rows']:
            raise IndexError("No such package found.")

        package = result['rows'][0]

        tmpl = "https://apps.fedoraproject.org/packages/images/icons/%s.png"
        url = tmpl % package['icon']
        response = requests.get(url)

        fd, filename = tempfile.mkstemp(suffix='.png')

        with open(filename, 'w') as f:
            if not response.raw.data:
                # Newer python-requests
                f.write(response.content)
            else:
                # Older python-requests
                f.write(response.raw.data)

        fab = fabulous.image.Image(filename)
        os.remove(filename)

        print(fab)
Esempio n. 2
0
    def take_action(self, args):
        import os
        import requests
        import tempfile
        import fabulous.image

        result = api.search(args.package, rows_per_page=1, start_row=0)

        if not result["rows"]:
            raise IndexError("No such package found.")

        package = result["rows"][0]

        tmpl = "https://apps.fedoraproject.org/packages/images/icons/%s.png"
        url = tmpl % package["icon"]
        response = requests.get(url)

        fd, filename = tempfile.mkstemp(suffix=".png")

        with open(filename, "w") as f:
            f.write(response.raw.data)

        fab = fabulous.image.Image(filename)
        os.remove(filename)

        print(fab)
Esempio n. 3
0
    def take_action(self, args):
        import os
        import requests
        import tempfile
        import fabulous.image

        result = api.search(
            args.package,
            rows_per_page=1,
            start_row=0,
        )

        if not result['rows']:
            raise IndexError("No such package found.")

        package = result['rows'][0]

        tmpl = "https://apps.fedoraproject.org/packages/images/icons/%s.png"
        url = tmpl % package['icon']
        response = requests.get(url)

        fd, filename = tempfile.mkstemp(suffix='.png')

        with open(filename, 'w') as f:
            if not response.raw.data:
                # Newer python-requests
                f.write(response.content)
            else:
                # Older python-requests
                f.write(response.raw.data)

        fab = fabulous.image.Image(filename)
        os.remove(filename)

        print(fab)
Esempio n. 4
0
 def test_search(self):
     """ Test the search function of the API. """
     guake_search = search(PKG)
     self.assertEqual(guake_search['rows'][0]['upstream_url'],
                      'http://www.guake.org/')
     self.assertEqual(guake_search['rows'][0]['devel_owner'], 'pingou')
     self.assertEqual(guake_search['rows'][0]['link'], PKG)
Esempio n. 5
0
 def test_search(self):
     """ Test the search function of the API. """
     guake_search = search(PKG)
     self.assertEqual(guake_search['rows'][0]['upstream_url'],
                      'http://www.guake.org/')
     self.assertEqual(guake_search['rows'][0]['devel_owner'],
                      'pingou')
     self.assertEqual(guake_search['rows'][0]['link'], PKG)
Esempio n. 6
0
 def take_action(self, args):
     columns = ['name', 'summary']
     result = api.search(
         args.package,
         rows_per_page=args.rows_per_page,
         start_row=args.start_row,
     )
     rows = result['rows']
     return (
         columns,
         [[row[col] for col in columns] for row in rows],
     )
Esempio n. 7
0
 def take_action(self, args):
     columns = ['name', 'summary']
     result = api.search(
         args.package,
         rows_per_page=args.rows_per_page,
         start_row=args.start_row,
     )
     rows = result['rows']
     return (
         columns,
         [[row[col] for col in columns] for row in rows],
     )
Esempio n. 8
0
    def take_action(self, args):
        result = api.search(args.package, rows_per_page=1, start_row=0)

        if not result["rows"]:
            raise IndexError("No such package found.")

        package = result["rows"][0]

        package["link"] = "https://apps.fedoraproject.org/packages/%s" % package["link"]
        del package["sub_pkgs"]  # TODO -- handle sub packages correctly.
        del package["icon"]  # TODO -- use python-fabulous
        package["name"] = args.package

        return (package.keys(), package.values())
Esempio n. 9
0
    def take_action(self, args):
        columns = ['name', 'summary']
        result = api.search(
            args.package,
            rows_per_page=args.rows_per_page,
            start_row=args.start_row,
        )

        final_rows = []
        for row in result['rows']:
            final_rows.append(row)
            for sub_package in row['sub_pkgs']:
                sub_package['name'] = "  " + sub_package['name']
                final_rows.append(sub_package)

        return (
            columns,
            [[row[col] for col in columns] for row in final_rows],
        )
Esempio n. 10
0
    def take_action(self, args):
        result = api.search(
            args.package,
            rows_per_page=1,
            start_row=0,
        )

        if not result['rows']:
            raise IndexError("No such package found.")

        package = result['rows'][0]

        package['link'] = "https://apps.fedoraproject.org/packages/%s" % \
                package['link']
        del package['sub_pkgs']  # TODO -- handle sub packages correctly.
        del package['icon']  # TODO -- use python-fabulous
        package['name'] = args.package

        return (package.keys(), package.values())
Esempio n. 11
0
    def take_action(self, args):
        columns = ['name', 'summary']
        result = api.search(
            args.package,
            rows_per_page=args.rows_per_page,
            start_row=args.start_row,
        )

        final_rows = []
        for row in result['rows']:
            final_rows.append(row)
            for sub_package in row['sub_pkgs']:
                sub_package['name'] = "  " + sub_package['name']
                final_rows.append(sub_package)

        return (
            columns,
            [[row[col] for col in columns] for row in final_rows],
        )
Esempio n. 12
0
    def take_action(self, args):
        result = api.search(
            args.package,
            rows_per_page=1,
            start_row=0,
        )

        if not result['rows']:
            raise IndexError("No such package found.")

        package = result['rows'][0]

        match = False

        for pkg in result['rows']:
            if pkg['name'] == args.package:
                match = True

            for sub_pkg in pkg['sub_pkgs']:
                if sub_pkg['name'] == args.package:
                    package['name'] = sub_pkg['name']
                    package['description'] = sub_pkg['description']
                    package['summary'] = sub_pkg['summary']
                    package['name'] = sub_pkg['name']
                    package['link'] = sub_pkg['link']
                    match = True
                    break

        if match is False:
            raise IndexError("No such package found.")

        package['link'] = "https://apps.fedoraproject.org/packages/%s" % \
                package['link']
        del package['sub_pkgs']  # TODO -- handle sub packages correctly.
        del package['icon']  # TODO -- use python-fabulous
        package['name'] = args.package

        return (package.keys(), package.values())
Esempio n. 13
0
    def take_action(self, args):
        result = api.search(
            args.package,
            rows_per_page=1,
            start_row=0,
        )

        if not result['rows']:
            raise IndexError("No such package found.")

        package = result['rows'][0]

        match = False

        for pkg in result['rows']:
            if pkg['name'] == args.package:
                match = True

            for sub_pkg in pkg['sub_pkgs']:
                if sub_pkg['name'] == args.package:
                    package['name'] = sub_pkg['name']
                    package['description'] = sub_pkg['description']
                    package['summary'] = sub_pkg['summary']
                    package['name'] = sub_pkg['name']
                    package['link'] = sub_pkg['link']
                    match = True
                    break

        if match is False:
            raise IndexError("No such package found.")

        package['link'] = "https://apps.fedoraproject.org/packages/%s" % \
                package['link']
        del package['sub_pkgs']  # TODO -- handle sub packages correctly.
        del package['icon']  # TODO -- use python-fabulous
        package['name'] = args.package

        return (package.keys(), package.values())
Esempio n. 14
0
 def take_action(self, args):
     columns = ["name", "summary"]
     result = api.search(args.package, rows_per_page=args.rows_per_page, start_row=args.start_row)
     rows = result["rows"]
     return (columns, [[row[col] for col in columns] for row in rows])