Пример #1
0
#!/usr/bin/env python3.4

from rc.clients import APIClient
import sys

if __name__ == '__main__':
  # If the base variables RC_PUBLIC_KEY and RC_PRIVATE_KEY 
  # are not set you need to pass the public and private key
  # values into this constructor
  client = APIClient()

  username = input("Username: "******"Invalid username")
  else:
    user = users[0]
    
    user_id = user['id']
    projects = client.projects(leaders=user_id)

    for project in projects:
      print(project['name'])
#!/usr/bin/env python3

from rc.clients import APIClient

if __name__ == '__main__':
  """
  Lists all the usernames of Users
  who have used the Drill Press.
  """

  # If the bash variables RC_PUBLIC_KEY and RC_PRIVATE_KEY 
  # are not set you need to pass the public and private key
  # values into this constructor
  client = APIClient()

  tooltron_id = client.projects(name="Tooltron")[0]['id']

  api_requests = client.api_requests(endpoint='/rfid/', updater_is_project=True, updater_id=tooltron_id, meta="Drill Press")

  for api_request in api_requests:
    user_id = api_request['user']

    if user_id:
      user = client.user(id=user_id)
      print("{} was {} access on Drill Press from {} until {}".format(user['username'], "Granted" if api_request['success'] else "Denied", api_request['created_datetime'], api_request['updated_datetime']))
Пример #3
0
#!/usr/bin/env python3

from rc.clients import APIClient

if __name__ == '__main__':
  """
  Given a valid RFID attempts to lookup
  the User's ID.  Then using that User ID,
  if it exists, get more information about the User.
  """

  # If the bash variables RC_PUBLIC_KEY and RC_PRIVATE_KEY 
  # are not set you need to pass the public and private key
  # values into this constructor
  client = APIClient()

  rfid = input("RFID: ")

  # Ask the API who this RFID corresponds to
  (user_id, api_request_id) = client.rfid(rfid, "Some Meta String")

  if user_id is None:
    print("No such User")
  else:
    # Get more information about the user
    user = client.user(user_id)

    print("Username: {}".format(user['username']))
Пример #4
0
#!/usr/bin/env python3

from rc.clients import APIClient

if __name__ == '__main__':
  """
  Lists all the usernames of Users
  who have used the CardReader project.
  """

  # If the bash variables RC_PUBLIC_KEY and RC_PRIVATE_KEY 
  # are not set you need to pass the public and private key
  # values into this constructor
  client = APIClient()

  cardreader_id = client.projects(name="CardReader")[0]['id']

  api_requests = client.api_requests(endpoint='/magnetic/', updater_is_project=True, updater_id=cardreader_id)

  for api_request in api_requests:
    user_id = api_request['user']

    if user_id:
      user = client.user(id=user_id)
      print("{} used CardReader on {}".format(user['username'], api_request['created_datetime']))
Пример #5
0
 def test_social_medias(self):
   client = APIClient()
   self.assertGreaterEqual(len(client.social_medias()), 1)
Пример #6
0
 def test_users(self):
   client = APIClient()
   self.assertGreaterEqual(len(client.users()), 1)
Пример #7
0
  def test_channels(self):
    client = APIClient()

    self.assertGreaterEqual(len(client.channels()), 1)
Пример #8
0
 def test_tshirts(self):
   client = APIClient()
   self.assertGreaterEqual(len(client.tshirts()), 1)
Пример #9
0
 def test_sponsors(self):
   client = APIClient()
   self.assertGreaterEqual(len(client.sponsors()), 1)
Пример #10
0
 def test_webcams(self):
   client = APIClient()
   self.assertGreaterEqual(len(client.webcams()), 1)
Пример #11
0
 def test_projects(self):
   client = APIClient()
   self.assertGreaterEqual(len(client.projects()), 1)
Пример #12
0
#!/usr/bin/env python3

from rc.clients import APIClient

if __name__ == '__main__':
  """
  Get information about the item with the specified UPC.
  """

  # If the bash variables RC_PUBLIC_KEY and RC_PRIVATE_KEY 
  # are not set you need to pass the public and private key
  # values into this constructor
  client = APIClient()

  while True:
    upc = input("UPC: ")

    item = client.upcs(upc=upc)

    if len(item):
      item = item[0]

      print("{} (${})".format(item['name'], item['cost']))
    else:
      print("No such item")
from rc.clients import APIClient

if __name__ == '__main__':
  """
  Given a valid RFID attempts to lookup
  the User's ID.  Then using that User ID,
  if it exists, get more information about the User.
  The User will only be granted access to our imaginary
  service if their first_name is 'Brent'.
  """

  # If the bash variables RC_PUBLIC_KEY and RC_PRIVATE_KEY 
  # are not set you need to pass the public and private key
  # values into this constructor
  client = APIClient()

  rfid = input("RFID: ")

  # Ask the API who this RFID corresponds to
  (user_id, api_request_id) = client.rfid(rfid, "Some Meta String")

  # Can modify the APIRequest to give more information
  # to the User(and Officers) about what this operation
  # was for
  print("APIRequest ID: {}".format(api_request_id))

  if user_id is None:
    print("No such User")
  else:
    # Get more information about the user