Exemplo n.º 1
0
 def __init__(self,
              function,
              arg_fields,
              path=None,
              methods=None,
              key=None,
              retype=None,
              client_mode=False,
              on_class=False):
     """
     :param function:
     :param arg_fields:
     :param path:
     :param methods:
     :param key:
     :param retype:
     :param client_mode:
     :param on_class: if open this flag, will ignore first argument (cls/self)
     :return:
     """
     self.methods = methods
     self.signature = signature.Signature(function, {})
     self.arg_fields = arg_fields
     self.support_get = self.signature.in_base_type
     self.original_callable = function
     self.key = key or self.signature.full_name
     arg_spec = inspect.getargspec(function)
     self.args = set(arg_spec.args)
     self.path = path or (self.default_path_template % self.key)
     self.retype = retype
     self.client_mode = client_mode
     self.on_class = on_class
     self.path_args = set([
         fname for _, fname, _, _ in self.url._formatter_parser() if fname
     ])
Exemplo n.º 2
0
    def instantiate(self, call_stack=[]):
        """
        Returns a node instance.
        :param call_stack: the list of NodeFactory id already in call stack
        (in order to avoir infinite recursion)
        """

        # The module contains the node implementation.
        module = self.get_node_module()
        classobj = module.__dict__.get(self.nodeclass_name, None)

        if classobj is None:
            raise Exception("Cannot instantiate '" + \
                self.nodeclass_name + "' from " + str(module))

        # If class is not a Node, embed object in a Node class
        if(not hasattr(classobj, 'mro') or not AbstractNode in classobj.mro()):

            # Check inputs and outputs
            if(self.inputs is None):
                sign = sgn.Signature(classobj)
                self.inputs = sign.get_parameters()
            if(self.outputs is None):
                self.outputs = (dict(name="out", interface=None),)


            # Check and Instantiate if we have a functor class
            if((type(classobj) == types.TypeType)
               or (type(classobj) == types.ClassType)):

                _classobj = classobj()
                if callable(_classobj):
                    classobj = _classobj

            node = FuncNode(self.inputs, self.outputs, classobj)

        # Class inherits from Node
        else:
            try:
                node = classobj(self.inputs, self.outputs)
            except TypeError, e:
                node = classobj()
Exemplo n.º 3
0
    keySize = IntVar()
    keySize.set(1024)
    Radiobutton(win, text='1024', value=1024, variable=keySize).grid(row=5,
                                                                     column=2)
    Radiobutton(win, text='2048', value=2048, variable=keySize).grid(row=5,
                                                                     column=3)
    Radiobutton(win, text='4096', value=4096, variable=keySize).grid(row=5,
                                                                     column=4)
    Button(win,
           text='Generate key pair',
           command=lambda: asimObject.generate(keySize, algorithm)).grid(
               row=7, column=3)


signObject = signature.Signature()


def signWindow():
    win = Toplevel()
    win.geometry('600x300+400+100')

    Label(win, text='Choose hash algorithm:').grid(row=0, column=2, sticky=E)
    hash_function = StringVar()
    hash_function.set("sha1")
    OptionMenu(win, hash_function, "sha1", "sha256", "sha512", "sha3_256",
               "sha3_512").grid(row=0, column=3)

    Label(win, text='Input:').grid(row=1, column=1)
    input_path = StringVar()
    Entry(win, textvariable=input_path, width=50).grid(row=1, column=2)
Exemplo n.º 4
0
 def UniqueSignatures(self):
     qry = queries.signature_star
     rawsigs = self.qdb.execQuery(qry)
     for id, ps in rawsigs:
         yield signature.Signature(id, ps, self.qdb)