def _login(self, page):
    print >>sys.stderr, 'Login %s' % self.username

    login_link = page.find('a', text='Log in')
    if not login_link:
      ErrorExit('unable to find login link')
    if not login_link.has_attr('href'):
      ErrorExit('unable to find login link')

    login_page = DevCenterPage(self._fetchUrl(login_link['href']))
    login_form = login_page.find(attrs={'name':'appleConnectForm'})
    if not login_form:
      ErrorExit('unable to find login form')

    form_fields = {}
    for field in login_form.find_all('input'):
      if field['type'] == 'hidden':
        if field.get('value'):
          form_fields[field['name']] = field['value']
      elif field['name'] == 'theAccountName':
        form_fields[field['name']] = self.username
      elif field['name'] == 'theAccountPW':
        form_fields[field['name']] = self.password

    url = '%s%s' % (self._baseUrl(login_page.url), login_form['action'])
    login_page = DevCenterPage(self._fetchUrl(url, urllib.urlencode(form_fields)))
    if login_page.loginNeeded():
      ErrorExit('login failed')
dataset/ETHPy150Open viewfinderco/viewfinder/clients/ios/scripts/app-tool.py/DevCenterClient._login/original