Coder Social home page Coder Social logo

Comments (9)

umihico avatar umihico commented on June 3, 2024

@faizanalhassan

Thank you for reporting. I didn't know inspect.getsource can't work in interactive mode. I guess you can run if you save readme script on files. Could you try that?

#31 is not perfect solution, just telling people more friendly that you can't use this in interactive mode.

from pythonista-chromeless.

faizanalhassan avatar faizanalhassan commented on June 3, 2024

Thanks for your help. that error is gone.
However, the script is still not running. I am getting another error:

Function not found: arn:aws:lambda:us-west-2:<aws account id>:function:chromeless-server-prod

You can see the region its referring is us-west-2, but the command I ran was sls deploy --region us-east-2. Is there anything I am missing? Any env or updates in serverless.yml?

from pythonista-chromeless.

faizanalhassan avatar faizanalhassan commented on June 3, 2024

My bad, there was another npm package named sls, which was doing trouble.
Uninstalled it.
Thanks again.

from pythonista-chromeless.

faizanalhassan avatar faizanalhassan commented on June 3, 2024

Lambda deployed successfully, but still getting same error:
arn:aws:lambda:us-west-2:<aws account id>:function:chromeless-server-prod
How do i tell Chromeless to target my region us-east-2?

from pythonista-chromeless.

umihico avatar umihico commented on June 3, 2024

@faizanalhassan
I'm glad to hear that the former problems are gone.

What output will you get if you execute aws configure get region in shell?

First, you need to deploy by sls deploy --region us-east-2.
Second, setting environmental variable works like AWS_DEFAULT_REGION=us-west-2 python main.py
Or, hard-coding in script is also possible like below.

from chromeless import Chromeless
import boto3 # This
boto3.setup_default_session(region_name='us-east-2') # This

def get_title(self, url):
    self.get(url)
    return self.title

chrome = Chromeless()
chrome.attach(get_title)
print(chrome.get_title("https://example.com"))

If you don't mind setting us-east-2 as your default region so far, I'd recommend aws configure set region us-east-2 and above modifications are probably not necessary, but deployment.

from pythonista-chromeless.

faizanalhassan avatar faizanalhassan commented on June 3, 2024

Yeah, actually I have multiple AWS profiles, so that might be causing this. I also set region_name in boto3, but the env way you shared is better AWS_DEFAULT_REGION, so will try that.
As always again thanks.

from pythonista-chromeless.

faizanalhassan avatar faizanalhassan commented on June 3, 2024

However, I suggest to accept aws key, secret and region in Chromeless.__init__, with default None, so the user can set through env, AWS local config, or explicitly pass to the constructor like in boto3. If you agree with this suggestion, I can do these updates and create a PR.

from pythonista-chromeless.

umihico avatar umihico commented on June 3, 2024

Yes, I agree with your idea and PR is always welcome, thank you!

Instead of accepting credentials directly, I think __init__ should accept 'session', then session can take care of credentials or profile

from boto3.session import Session

session = Session(aws_access_key_id='<YOUR ACCESS KEY ID>',
                  aws_secret_access_key='<YOUR SECRET KEY>',
                  region_name='<REGION NAME>')
# or
session = Session(profile_name='<YOUR_PROFILE_NAME>')

from pythonista-chromeless.

faizanalhassan avatar faizanalhassan commented on June 3, 2024

Ok doing with session object. Will update you in a day or two. Thanks for accepting my contributions.

from pythonista-chromeless.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.