Esempio n. 1
0
    def __init__(self, id, filename=None):

        try:
            r = requests.get('https://gdata.youtube.com/feeds/api/videos/{0}?alt=json'.format(str(id)))
            self.entry = dotdict(r.json()["entry"])
            self.entry["found"] = "ok"
        except:
            self.entry = dotdict()
            self.entry.title = {'$t': None}
            self.entry.content = {'$t': None}
            self.entry.id = {'$t': 'https://gdata.youtube.com/feeds/api/videos/{0}?alt=json'.format(str(id))}
            self.entry.updated = {'$t': None}
            self.entry["found"] = "-"

        self.entry["watch"] = "https://www.youtube.com/watch?v={0}".format(str(id))
        self.entry["filename"] = filename
        self.entry['number'] = id
Esempio n. 2
0
    def __init__(self, id, filename=None):

        try:
            r = requests.get(
                'https://gdata.youtube.com/feeds/api/videos/{0}?alt=json'.
                format(str(id)))
            self.entry = dotdict(r.json()["entry"])
            self.entry["found"] = "ok"
        except:
            self.entry = dotdict()
            self.entry.title = {'$t': None}
            self.entry.content = {'$t': None}
            self.entry.id = {
                '$t':
                'https://gdata.youtube.com/feeds/api/videos/{0}?alt=json'.
                format(str(id))
            }
            self.entry.updated = {'$t': None}
            self.entry["found"] = "-"

        self.entry["watch"] = "https://www.youtube.com/watch?v={0}".format(
            str(id))
        self.entry["filename"] = filename
        self.entry['number'] = id
Esempio n. 3
0
    def do_yaml(self, args, arguments):
        """
        ::

          Usage:
              yaml KIND [KEY] [--filename=FILENAME] [--format=FORMAT]
              yaml KIND KEY VALUE [--filename=FILENAME] 

          Provides yaml information or updates yaml on a given replacement

          Arguments:
              KIND        The type of the yaml file (server, user) 
              KEY         Key name of the nested dict e.g. cloudmesh.server.loglevel
              VALUE       Value to set on a given KEY
              FILENAME    cloudmesh.yaml or cloudmesh_server.yaml
              FORMAT      The format of the output (table, json, yaml)

          Options:

              --format=FORMAT      the format of the output [default: print]

          Description:

             Sets and gets values from a yaml configuration file
        """

        #
        # use dot notation to make things better readable
        #
        arguments['value'] = arguments.pop('VALUE')
        arguments['kind'] = arguments.pop('KIND')
        arguments['key'] = arguments.pop('KEY')
        arguments['format'] = arguments.pop('--format')
        arguments['filename'] = arguments.pop('--filename')
        arguments = dotdict(arguments)

        #
        # List functions
        #

        if arguments.kind not in ['user', 'server']:
            Console.error("the specified kind does not exist")
            return
        else:
            if arguments.kind == 'user':
                config = self.cm_config
            elif arguments.kind == 'server':
                config = self.cm_config_server
            arguments.filename = arguments.filename or config.filename
            config.load(arguments.filename)

        if not arguments.value:

            if not arguments.key and not arguments.value:
                if arguments.format == "print":
                    print(config.pprint())
                elif arguments.format == 'json':
                    print(config.json())
                elif arguments.format == 'yaml':
                    print(config.yaml())
                else:
                    Console.error("format not supported")
                return
            elif arguments.key and not arguments.value:
                print(config.get(arguments.key))

            return

        else:
            #
            # SETTING VALUES
            #

            config._update(arguments.key, arguments.value)
            # config.pprint()
            config['meta']['location'] = arguments.filename
            config.write(output="yaml")

            self.config = config
Esempio n. 4
0
    def do_yaml(self, args, arguments):
        """
        ::

          Usage:
              yaml KIND [KEY] [--filename=FILENAME] [--format=FORMAT]
              yaml KIND KEY VALUE [--filename=FILENAME] 

          Provides yaml information or updates yaml on a given replacement

          Arguments:
              KIND        The type of the yaml file (server, user) 
              KEY         Key name of the nested dict e.g. cloudmesh.server.loglevel
              VALUE       Value to set on a given KEY
              FILENAME    cloudmesh.yaml or cloudmesh_server.yaml
              FORMAT      The format of the output (table, json, yaml)

          Options:

              --format=FORMAT      the format of the output [default: print]

          Description:

             Sets and gets values from a yaml configuration file
        """
        
        #
        # use dot notation to make things better readable
        #
        arguments['value'] = arguments.pop('VALUE')                        
        arguments['kind'] = arguments.pop('KIND')                
        arguments['key'] = arguments.pop('KEY')        
        arguments['format'] = arguments.pop('--format')
        arguments['filename'] = arguments.pop('--filename')        
        arguments = dotdict(arguments)
        
        #
        # List functions
        #

        if arguments.kind not in ['user','server']:
            Console.error("the specified kind does not exist")
            return
        else:
            if arguments.kind == 'user':
                config = self.cm_config
            elif arguments.kind == 'server':
                config = self.cm_config_server
            arguments.filename = arguments.filename or config.filename
            config.load(arguments.filename)

        
        if not arguments.value:

            if not arguments.key and not arguments.value:
                if arguments.format == "print":
                    print(config.pprint())
                elif arguments.format == 'json':
                    print(config.json())
                elif arguments.format == 'yaml':
                    print(config.yaml())
                else:
                    Console.error("format not supported")
                return
            elif arguments.key and not arguments.value:
                print(config.get(arguments.key))

            return

        else:
        #
        # SETTING VALUES
        #

            config._update(arguments.key, arguments.value)
            # config.pprint()
            config['meta']['location'] = arguments.filename
            config.write(output="yaml")

            self.config = config