コード例 #1
0
def fillCustomers():
    src = "resources//customers.json"
    with open(src, "r") as f:
        for line in f:
            print(line)
            cust = Customer(line)
            backend.add(cust)
コード例 #2
0
def fillBus():
    src = "resources//bus.json"
    with open(src, "r") as f:
        for line in f:
            print(line)
            cust = Bus(line)
            backend.add(cust)
コード例 #3
0
ファイル: front.py プロジェクト: batbeerman/BOOK_DIRECTORY
def add_():
    #Button for Adding Entry
    backend.add(title_text.get(), author_text.get(), year_text.get(),
                isbn_text.get())
    listing.delete(0, END)
    listing.insert(END, (title_text.get(), author_text.get(), year_text.get(),
                         isbn_text.get()))
コード例 #4
0
def fillFlights():
    src = "resources//flights.json"
    with open(src, "r") as f:
        for line in f:
            print(line)
            cust = Flight(line)
            backend.add(cust)
コード例 #5
0
def fillHotels():
    src = "resources//hotels.json"
    with open(src, "r") as f:
        for line in f:
            print(line)
            cust = Hotel(line)
            backend.add(cust)
コード例 #6
0
ファイル: accpsswd.py プロジェクト: 7absec/Passworx
def adder():
    bck.add(account_text.get(), name_text.get(), userid_text.get(),
            password_text.get(), note_text.get(), date_text.get())
    lb.delete(0, END)
    lb.insert(END, 'account : ' + account_text.get(),
              'name : ' + name_text.get(), 'userid : ' + userid_text.get(),
              'password : '******'note : ' + note_text.get(),
              'date : ' + date_text.get())
コード例 #7
0
def add_command():

    backend.add(title_text.get(), author_text.get(), year_text.get(),
                isbn_text.get())

    # Delete Entries from Previous Button Clicks and Display Added Entry
    book_list.delete(0, END)
    book_list.insert(END,
                     (title_text.get(), author_text.get(), year_text.get(),
                      isbn_text.get()))
コード例 #8
0
ファイル: frontend.py プロジェクト: fallingduck/enclave
    def add_new(self, event):
        which_function = wx.SingleChoiceDialog(self, 'What do you want to add?',
            'Add...', choices=['Friend', 'Group Chat'])
        which_function.ShowModal()

        if which_function.GetStringSelection() == 'Friend':
            name_prompt = wx.TextEntryDialog(self, "Enter friend's name...",
                caption='Add Friend...')
            name_prompt.ShowModal()
            name = name_prompt.GetValue()
            if name:
                address_prompt = wx.TextEntryDialog(self,
                    "Enter friend's cjdns address...", caption='Add Friend...')
                address_prompt.ShowModal()
                address = address_prompt.GetValue()

                name, peer = backend.add(address, name)
                if peer in self.friends_by_obj:
                    index = self.friends_by_obj.index(peer)
                    self.friends_by_name[index] = name

                else:
                    self.friends_by_name.append(name)
                    self.friends_by_obj.append(peer)
                    self.friendlist.Insert(name, len(self.friends_by_name) - 1)
コード例 #9
0
    def add_new(self, event):
        which_function = wx.SingleChoiceDialog(
            self,
            'What do you want to add?',
            'Add...',
            choices=['Friend', 'Group Chat'])
        which_function.ShowModal()

        if which_function.GetStringSelection() == 'Friend':
            name_prompt = wx.TextEntryDialog(self,
                                             "Enter friend's name...",
                                             caption='Add Friend...')
            name_prompt.ShowModal()
            name = name_prompt.GetValue()
            if name:
                address_prompt = wx.TextEntryDialog(
                    self,
                    "Enter friend's cjdns address...",
                    caption='Add Friend...')
                address_prompt.ShowModal()
                address = address_prompt.GetValue()

                name, peer = backend.add(address, name)
                if peer in self.friends_by_obj:
                    index = self.friends_by_obj.index(peer)
                    self.friends_by_name[index] = name

                else:
                    self.friends_by_name.append(name)
                    self.friends_by_obj.append(peer)
                    self.friendlist.Insert(name, len(self.friends_by_name) - 1)
コード例 #10
0
def home():
    if request.method == "POST":
        first = float(request.form['first'])
        second = float(request.form['second'])
        sum_ = backend.add(first, second)
        return FORM_SENT_TEMPLATE.format(first=first, second=second, sum=sum_)
    else:
        return HOME_PAGE
コード例 #11
0
    def commitChanges(self, *args):
        mode = self.mode.get()
        op = self.op.get()

        #Construct object
        if(mode == "Flight"):
            obj = backend.Flight((
                self.primaryKey.get(),
                int(self.price.get()),
                int(self.totalNum.get()),
                int(self.availNum.get()),
                self.fromCity.get(),
                self.arivCity.get(),
                self.param.get()
            ))
        elif(mode == "Hotel"):
            obj = backend.Hotel((
                self.primaryKey.get(),
                self.location.get(),
                int(self.price.get()),
                int(self.totalNum.get()),
                int(self.availNum.get()),
                self.param.get()
            ))
        else:
            obj = backend.Bus((
                self.primaryKey.get(),
                self.location.get(),
                int(self.price.get()),
                int(self.totalNum.get()),
                int(self.availNum.get()),
                self.param.get()
            ))
            
        # print(obj)

        # Sends to dbUpdate
        if(op == "Add New"):
            backend.add(obj)
        else:
            backend.update(obj)
コード例 #12
0
def add_command():
    result_listbox.delete(0,END)
    backend.add(title_text.get(),author_text.get(),year_text.get(),isbn_text.get())
    result_listbox.insert(END,title_text.get(),author_text.get(),year_text.get(),isbn_text.get())
コード例 #13
0
def add_command():
    backend.add(title_value.get(),author_value.get(),year_value.get(),isbn_value.get())
    lb1.delete(0,END)
    lb1.insert(END,(title_value.get(),author_value.get(),year_value.get(),isbn_value.get()))
コード例 #14
0
 def test():
     a = 50
     b = 70
     expected = 120
     got = add(a, b)
     it.assertEqual(got, expected)
コード例 #15
0
 def add_command(self):
     """Insert entry via button."""
     backend.add(self.title.get(), self.author.get(), self.year.get(), self.isbn.get(), self.lang.get(), self.placed.get())
     self.l.delete(0, END)
     self.l.insert(END, (self.title.get(), self.author.get(), self.year.get(), self.isbn.get(), self.lang.get(), self.placed.get()))
コード例 #16
0
 def addd():
     if (len(patid.get()) != 0):
         backend.add(patid.get(), patfn.get(), patln.get(), patdr.get(),
                     patage.get(), patgender.get(), patadd.get(),
                     patmob.get(), patdr.get())
     messagebox.showinfo("information", "Added Succesfully")
コード例 #17
0
def add_command():
    if not all(x == '' for x in (e1.get(), e2.get(), e3.get(), e4.get())):
        be.add(title=e1.get(), author=e2.get(), year=e3.get(),
               isbn=e4.get())  #u
        view_command()
コード例 #18
0
ファイル: frontend.py プロジェクト: Parent5446/cooper-redhen
    def post(self):
        """
        Handle a POST request to the API.
        
        Take a list of actions from a POST request, and do the appropriate
        action. See the documentation for this module for more information.
        
        @raise common.InputError: If no search targets are given in the target
        POST variable or if an invalid action is given.
        """
        cpu_start = quota.get_request_cpu_usage()
        
        action = self.request.get("action")
        target = self.request.get("target", "public")
        spectra = self.request.get_all("spectrum") #Some of these will be in session data
        limit = self.request.get("limit", 10)
        offset = self.request.get("offset", 0)
        algorithm = self.request.get("algorithm", "bove")
        guess = self.request.get("guess")
        spectrum_type = self.request.get("type")
        raw = self.request.get("raw", False)
        session = appengine_utilities.sessions.Session()
        user = users.get_current_user()
        response = []
        
        # First check if the user has gone over quota.
        if session.get("cpu_usage") > self.CPU_LIMIT:
            raise common.ServerError("User has gone over quota.")
        
        spectra = [open('jcamp-test.jdx').read()] # Just for testing

        # If not operating on the main project, try getting the private one.
        # But abort if target is not supposed to be a project.
        if target and target != "public":
            target = backend.Project.get(target)
            if target is None:
                raise common.InputError(targets, "Invalid project ID.")
        # Start doing the request
        if action == "compare" and target == "public":
            # Search the database for something.
            for spectrum in spectra:
                # User wants to commit a new search with a file upload.
                result = backend.search(spectrum)
                # Extract relevant information and add to the response.
                response = [(str(i.key()), i.chemical_name, i.error, i.graph_data) for i in result]
        elif action == "compare":
            # Compare multiple spectra uploaded in this session.
            response.append(backend.compare(spectra, algorithm))
        elif action == "browse":
            # Get a list of spectra from the database for browsing
            backend.auth(user, target, "view")
            # Return the database key, name, and chemical type.
            results = [(str(spectrum.key()), spectrum.chemical_name, spectrum.chemical_type)
                       for spectrum in backend.browse(target, limit, offset, guess, spectrum_type)]
            response.extend(results)
        elif action == "add":
            # Add a new spectrum to the database. Supports multiple spectra.
            backend.auth(user, target, "spectrum")
            for spectrum_data in spectra:
                backend.add(spectrum_data, target, False)
        elif action == "bulkadd":
            # Add a new spectrum to the database. Supports multiple spectra.
            if session.key().name() != "uploader":
                raise common.AuthError(user, "Only the uploader can bulkadd.")
            for spectrum_data in spectra:
                backend.add(spectrum_data, target, True)
        elif action == "delete":
            # Delete a spectrum from the database.
            backend.auth(user, target, "spectrum")
            for spectrum_data in spectra:
                backend.delete(spectrum_data, target)
        elif action == "update":
            backend.auth(user, "public", "spectrum")
            backend.update()
        elif action == "projects":
            query = "WHERE :1 IN owners OR :1 IN collaborators OR :1 in viewers"
            response.extend([(proj.key(), proj.name) for proj in Project.gql(query, user)])
        else:
            # Invalid action. Raise an error.
            raise common.InputError(action, "Invalid API action.")
        # Pass it on to self.output for processing.
        self.output(response)