Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

object of type 'bool' has no len() error message #10

Closed
kurtatwork opened this issue Nov 21, 2021 · 2 comments
Closed

object of type 'bool' has no len() error message #10

kurtatwork opened this issue Nov 21, 2021 · 2 comments

Comments

@kurtatwork
Copy link

i keep getting this error message, even though i have json files loaded in the data folder, when the selenium script runs, everything works great... metamask loads up, logs in, then opensea loads up and logs in with metamask... then it goes to the create NFT page and as soon as it tries to pull the data from the json and turn it into a list object and pass that data along to some function in the code, for whatever reason it seems to be interpreting the list to be boolean object rather than a list object, and it doesn't detect it having a length as a result. because of that, the properties in the json file don't seem to be detected (or they are just being passed through as true or false, idk). once it hits this spot in the process, (create NFT page) it basically hangs up on this and spits out this error message:

`main.py:189: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
driver = webdriver.Chrome(self.webdriver_path, options=options)

Login to MetaMask extension. Logged to Metamask extension.
Login to Opensea. Logged to Opensea.

Traceback (most recent call last):
File "main.py", line 775, in
settings.get_nft(element) # Get data of the NFT.
File "main.py", line 100, in get_nft
self.json_file()
File "main.py", line 147, in json_file
self.create_parameters(_list)
File "main.py", line 66, in create_parameters
self.levels: list = self.type_parameters(
File "main.py", line 85, in type_parameters
if len(parameters) > 0:
TypeError: object of type 'bool' has no len()`

Not really sure what's causing this... i've looked at the code for a while and i can't seem to find why this is happening. My json files are formatted in the correct structure so it shouldn't be that...

I'm sure this is something simple that i'm just overlooking.

@kurtatwork
Copy link
Author

i realized that my json file structure wasn't EXACTLY the same as the examples, as my NFT doesn't have levels or stats, so i didn't add that to the json object... as a result i needed to modify the main.py code to reflect that in the 'create_parameters' function

the str(parameters[x]) value needs to correspond with the data that you actually have in your json files... so if you don't have 'levels' or 'stats' in your json file, you're going to need to comment out the levels and stats part of the code, and then change the array value '[x]' to be in accordance with the actual layout of your json file... so after removing levels and stats, which would have been in places 6 and 7 in the parameters array, i needed to then array values following that, to account for those two not being there...

i also did not use the 'method' class in my json file, so i commented that out as well.

def create_parameters(self, parameters: list) -> None:
        """Create parameters."""
        # Upload:
        self.file_path = str(parameters[0])
        self.nft_name = str(parameters[1])
        self.external_link = parameters[2]
        self.description = str(parameters[3])
        self.collection = str(parameters[4])
        self.properties: list = self.type_parameters(
            parameters[5], 2)  # [[type, name], ...]

        # HAD TO EDIT THIS CODE BECAUSE MY NFT DOESN'T HAVE LEVELS OR STATS, and ALSO HAD TO REMOVE CERTAIN ITEMS IN THE paramaters array, because they aren't in my json file.
        # self.levels: list = self.type_parameters(
            # parameters[6], 3)  # [[name, from, to], ...]
        # self.stats: list = self.type_parameters(
            # parameters[7], 3)  # [[name, from, to], ...]
        
        
        self.unlockable_content: list = parameters[6]  # [bool, text]
        self.explicit_and_sensitive_content: bool = parameters[7]
        self.supply: int = parameters[8]
        self.blockchain: str = parameters[9]

        # Sell:
        self.type: str = parameters[10]
        self.price: int = parameters[11]
        # self.method: list = parameters[14]  # [method, price]
        self.duration: list = parameters[12]
        self.specific_buyer: list = parameters[13]
        self.quantity: int = parameters[14]

you'll also need to change the line of code where parameter is defined, for example:

# COMMENTED OUT OR DELETED settings.levels, AND settings.stats FROM parameters
# parameters = [settings.properties, settings.levels, settings.stats]
parameters = [settings.properties]

did this... and that seemed to fix it getting hung up at the create screen... now it actually adds the image, name, etc... adds the properties, but then when it gets to the part where it has to upload the stats and levels... its looking for parts in an array that no longer exist (because i took them out from paramaters array)

so, i had to comment out the following lines as well:

# if len(element) == 3:
                        #     actual_element = (
                        #         f'/html/body/div[{index + 2}]/div/div/div/'
                        #         f'section/table/tbody/tr[{parameter}]/td[3]'
                        #         '/div/div/input')
                        #     self.clear_text(actual_element)
                        #     self.element_send_keys(actual_element, element[2])
                        # actual_element = (
                        #     f'/html/body/div[{index + 2}]/div/div/div/section/'
                        #     f'table/tbody/tr[{parameter}]/td[2]/div/div/input')
                        # self.clear_text(actual_element)
                        # self.element_send_keys(actual_element, element[1])
                    # Click on "Save" button.

which brought up another issue around line 419 (may be somewhere else in your code because i changed mine)

basically the script checks the an array for a value in a certain place, and an error code is being thrown around line 419 because, again, object of type 'bool' has no len()... so to get around this i just hardcoded a variable called constUnlockableContent, set that to equal false, and in the part of the code where it would have checked the array, i just made it check to see if the value was true or not and if so, make the switch...

after that though, i found it easier to just comment that part of the code out entirely... all the 'if' statements relating to the unlockable content and explicit/sensitive content... which GOT IT TO WORK... now it can create the NFT's but gets hung up on the part afterward where it lists it for sale... gotta figure that out next.

@kurtatwork
Copy link
Author

I'm going to go ahead and mark this as closed, since the original issue has been figured out... i hope this info is helpful to someone else out there. it was pretty tough troubleshooting it on my own with very little documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant