0

I have been creating a web app that uses webapp2 framework and hosted with Google App Engine. So in order to run the webapp on LOCALHOST, I use the following command.

dev_appserver.py app.yaml

The python script that I am trying to run is in the same project folder as well, when the script is executed, I get the following error.

 File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py", line 256, in _MakeRealSyncCall
    raise pickle.loads(response_pb.exception())
RuntimeError: NotImplementedError()

I have no clue, why it is showing this error. I tried looking at python documentation.

exception NotImplementedError:

This exception is derived from RuntimeError. In user defined base classes, abstract methods should raise this exception when they require derived classes to override the method, or while the class is being developed to indicate that the real implementation still needs to be added.

https://docs.python.org/3/library/exceptions.html#NotImplementedError

As being new to programming, unfortunately it makes no sense to me.

I might be getting this error because of:

1.The application is running on different server and I am trying to run a script that is on my PC. But the demo I downloaded also has some python scripts that are been executed by clicking a button on html page and those work fine.

  1. The script I am trying to execute, uses selenium web driver, it might be conflicting with the webapp2 framework.

I am not sure, why is that happening. Any suggestions please. Thanks!

UPDATE

full traceback

Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\api_server.py", line 375, in _handle_POST
    api_response = _execute_request(request).Encode()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\api_server.py", line 231, in _execute_request
    make_request()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\api_server.py", line 226, in make_request
    request_id)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub.py", line 151, in MakeSyncCall
    method(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\remote_socket\_remote_socket_stub.py", line 234, in _Dynamic_Listen
    raise NotImplementedError()
NotImplementedError

Views.py

from handlers.api_handler import APIHandler
from handlers.ndb_handler import InitUser
import webapp2
import os
from google.appengine.ext.webapp import template



class Google_Login(webapp2.RequestHandler):
    def post(self):
        template_values = {
            'back_msg': 'View Campaigns'
        }
        try:
            app_user = InitUser()

            handler = APIHandler(app_user.client_id,
                                 app_user.client_secret,
                                 app_user.refresh_token,
                                 app_user.adwords_manager_cid,
                                 app_user.developer_token)

            handler.google_log()

            self.redirect('/showCampaigns?clientCustomerId=%s''{{ccid}}')
        except Exception as e:
           template_values['error'] = str(e)
           # Use template to write output to the page.
           path = os.path.join(os.path.dirname(__file__),
                               '../templates/base_template.html')
           self.response.out.write(template.render(path, template_values))

Api_handler.py (where the selenium webdriver is being used)

def google_log(self):  
          browser=webdriver.Firefox(executable_path=r'C:\Users\JASPREET\geckodriver.exe')
          browser.maximize_window()
          browser.get("https://accounts.google.com/ServiceLogin/identifier?continue=https%3A%2F%2Fadwords.google.com%2Fum%2Fidentity%3Fhl%3Den%26sourceid%3Dawo%26subid%3Dca-en-ha-g-aw-c-dr_df_1-b_ex!o2~-1340701349-261603328952-kwd-1329939046%26utm_campaign%3Dca-ww-di-g-aw-a-awhp_1!o2&hl=en&service=adwords&skipvpage=true&ltmpl=signin&flowName=GlifWebSignIn&flowEntry=AddSession")
          username=browser.find_element_by_css_selector('#identifierId')
          username.send_keys('#EMAIL')
          next=browser.find_element_by_css_selector('#identifierNext').click()
          time.sleep(1)
          password= browser.find_element_by_xpath("//input[@name='password']")
          password.send_keys('#PASSWORD')
          login=browser.find_element_by_xpath('//*[@id="passwordNext"]')
          login.click()
          time.sleep(3)

          browser.get('path to scripts')

          time.sleep(7)

          run=browser.find_element_by_xpath('/html/body/div[2]/root/div/div[1]/div[3]/awsm-child-content/div[2]/div/bulk-root/base-root/div[2]/div[1]/view-loader/script-editor-view/script-editor/div/buttonbar/pending-panel/div/div/material-button[2]').click()
          time.sleep(2)
          run_two=browser.find_element_by_xpath('/html/body/div[4]/div[2]/material-dialog/focus-trap/div[2]/div/footer/div/material-button[2]').click()

HTML FILE where I am calling the python script to execute "FB" is the name of view that links to API handler and calls the script.

<div class="">
    <form action="/fb?clientCustomerId = {{ccid}}" method="post">
      <input type="submit" name="" value="RUN">

    </form>
  </div>

UPDATE 2

APP.YAML

runtime: python27
api_version: 1
threadsafe: false

handlers:
- url: /stylesheets
  static_dir: stylesheets
- url: /js
  static_dir: js
- url: /.*
  script: demo.main.app
  login: required
  secure: always

libraries:
- name: ssl
  version: latest

MAIN.PY

"""App Engine application module.

Configures the web application that will display the AdWords UI.
"""


from demo import DEBUG
from views import AddAdGroup
from views import AddCampaign
from views import InitView
from views import ShowAccounts
from views import ShowAdGroups
from views import ShowBudget
from views import ShowCampaigns
from views import ShowCredentials
from views import UpdateBudget
from views import UpdateCredentials
from views import ShowPage
from views import ShowKeywords
from views import NonServing
from views import Google_Login

import webapp2


app = webapp2.WSGIApplication([('/', InitView),
                               ('/showCredentials', ShowCredentials),
                               ('/updateCredentials', UpdateCredentials),
                               ('/showAccounts', ShowAccounts),
                               ('/showCampaigns', ShowCampaigns),
                               ('/addCampaign', AddCampaign),
                               ('/showAdGroups', ShowAdGroups),
                               ('/addAdGroup', AddAdGroup),
                               ('/showBudget', ShowBudget),
                               ('/updateBudget', UpdateBudget),
                               ('/nonservingpause', NonServing),
                               ('/keywords', ShowKeywords),
                               ('/fb', Google_Login),
                               ],
                              debug=DEBUG)
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Can you show the full traceback and the code causing it? – Dan Cornilescu Apr 26 '18 at 21:26
  • I updated my post. @DanCornilescu – jaspreet sohal Apr 26 '18 at 22:21
  • 1
    The traceback indicates your app code is not even reached, which typically suggests an application config error. Can you show your `app.yaml`, the dev server log for the request causing the failure and your main app code? – Dan Cornilescu Apr 27 '18 at 04:49
  • I will second @DanCornilescu observation and the error have no relation with `Selenium`. – undetected Selenium Apr 27 '18 at 07:36
  • Updated with App.yaml and main.py @DanCornilescu – jaspreet sohal Apr 27 '18 at 13:02
  • If `main.py` is located side-by-side with `app.yaml` try replacing `script: demo.main.app` with `script: main.app` in your `app.yaml`. – Dan Cornilescu Apr 27 '18 at 15:56
  • It is demo.main.app because the main.py is located in the demo subfolder which acts as a module. If I remove demo from main.app, it would not recognize the file. @DanCornilescu. – jaspreet sohal Apr 28 '18 at 03:13
  • Hm, nope - a module is **everything** from the dir in which the respective `app.yaml` file exists. If you want just the `demo` dir to act as a module then I suggest moving `app.yaml` inside the `demo` dir, see also https://stackoverflow.com/questions/34110178/can-a-default-service-module-in-a-google-app-engine-app-be-a-sibling-of-a-non-de – Dan Cornilescu Apr 28 '18 at 04:10
  • If indeed you want the modules to overlap make sure all the intermediate directories to the `main.py` files are packages, i.e. each one of them contains an `__init__.py` file (in this case the `demo` dir) – Dan Cornilescu Apr 28 '18 at 04:25

0 Answers0