try mirroring webpage using pywebcopy - python-3.x

from pywebcopy.core import save_webpage
save_webpage(
url='http://example-site.com/index.html',
download_loc='d:/',
copy_all=True
)
I get this error when trying to run this program:
Traceback (most recent call last):
File "D:/untitled7/mirror.py", line 6, in
download_loc='d:/',
TypeError: save_webpage() missing 1 required positional argument: 'mirrors_dir'

For current version 6.0.0 as of github repo
You are using copy_all=True so I am guessing you want
to clone the whole website.
from pywebcopy import save_website
kwargs = {'project_name': 'some-fancy-name'}
save_website(
url='http://example-site.com/index.html',
project_folder='path/to/downloads',
**kwargs
)

Related

Python3 eyed3 module, reading comments from mp3 file?

My goal is to use python3 (3.8 preferred) to read and eventually set the comments tag on an MP3 file.
I have installed eyed3 (python3.8 -m pip install eyed3) and the following code will load and can read all the tags, except when it comes to the comments. I've tried reading the documentation from the creator's website (http://eyed3.nicfit.net/) and the GitHub site with no luck and I'm not fully understanding the output from the following code:
import eyed3
music = "/path/to/valid/music/file.mp3"
audio = eyed3.load(music)
print(audio.tag.comments)
this spits out the following:
<eyed3.id3.tag.CommentsAccessor object at 0x7f54ca55d2b0>
I've tried doing a dir(audio.tag.comments) and that doesn't provide anything except a bunch of class bits, and the following functions "get", "remove", "set"
       
Using something like:
moo = audio.tag.comments.get()
throws an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/mrhobbits/.local/lib/python3.8/site-packages/eyed3/utils/__init__.py", line 138, in wrapped_fn
return fn(*args, **kwargs)
TypeError: get() missing 1 required positional argument: 'description'
Yet I can't find anything that would show me what 'description' is, or maybe I have to drill deeper to get the comment information?
I should also mention that doing:
print(audio.tag.artist)
works just fine and returns:
Alestorm
I'm a bit lost here. Any help would be great.
Nevermind,
A quick search here revealed that the 'comments' is a list sort of object, and that doing:
audio.tag.comments[0].text
reveals the information I was looking for.

Excel Macro- Not able to run a .exe file

I am using the below code to run an application and even though the app is running it is not showing the desired results. But when I simply double-click the application it runs properly.
RetVal = Shell("D:\Automation Analyzer\Issue Type\dist\PatternDetectorAppv6.0.exe", 1)
The error that is coming on a popup after running this app via the above code is given below.
Traceback (most recent call last):
File "PatternDetectorAppv6.0.py", line 18, in <module>
File "configparser.py", line 959, in __getitem__
KeyError: 'FILE_PATH'
[19428] Failed to execute script PatternDetectorAppv6.0

ImportError: cannot import name 'entrenamiento'

I'm taking Python again after a long time.
I'm developing a little software to help me learn a new lengauge (japanese)
I tried to make a class and import it, but it did't work. Just for testing, I created a very simple class and when I tried to import it I got an error.
Here is the code (both files trainer.py and prueba.py are in the same folder):
file trainer.py
class trainer:
def entrenamiento(t,dicc):
print(t)
print(dicc)
file prueba.py
from trainer import entrenamiento
entrenamiento(1,2)
When I run prueba.py I get the following:
C:\Users\nico\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/nico/PycharmProjects/japanese/prueba.py
Traceback (most recent call last):
File "C:/Users/nico/PycharmProjects/japanese/prueba.py", line 1, in <module>
from trainer import entrenamiento
ImportError: cannot import name 'entrenamiento'
Process finished with exit code 1
I also tried with a different code in prueba.py:
import trainer
trainer.entrenamiento(1,2)
and I got this:
C:\Users\nico\AppData\Local\Programs\Python\Python36-32\python.exe
C:/Users/nico/PycharmProjects/japanese/prueba.py
Traceback (most recent call last):
File "C:/Users/nico/PycharmProjects/japanese/prueba.py", line 3, in <module>
trainer.entrenamiento(1,2)
AttributeError: module 'trainer' has no attribute 'entrenamiento'
Process finished with exit code 1
Finally, just for checking I tried the following
file trainer.py
class trainer:
print('hello world')
file prueba.py
import trainer
and I got no error
C:\Users\nico\AppData\Local\Programs\Python\Python36-32\python.exe
C:/Users/nico/PycharmProjects/japanese/prueba.py
hello world
Process finished with exit code 0
I'm working with Python 3.6.5 and PyCharm 2018.1.4 Community Edition
Is there any mistake in my coding or maybe a configuration issue?
I thank you in advance for your help
Uhm so, you made a little mistake with your import in prueba.py
it should be:
from trainer import trainer
trainer.entrenamiento(1,2)
where the first trainer points to trainer.pyand the second points to the class.
you can now access the function defined inside the class using the syntax class.function eg. trainer.entrenamiento(1,2)
i would recommend to change either the name of trainer.py or the class trainer as it's obviously confusing.

Mapreduce no longer works after 2.7 conversion

After converting our app to Python 2.7, configuring for multithreading, and referencing mapreduce in app.yaml like this...
- url: /mapreduce(/.*)?
script: mapreduce.main.app
#script: google.appengine.ext.mapreduce.main.app
login: admin
and invoking mapreduce like this...
control.start_map(
"FNFR",
"fnfr.fnfrHandler",
"mapreduce.input_readers.BlobstoreLineInputReader",
{"blob_keys": blobKey},
shard_count=32,
mapreduce_parameters={'done_callback': '/fnfrdone','blobKey': blobKey, 'userID':thisUserID})
we get the following stack trace...
Traceback (most recent call last):
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 189, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 241, in _LoadHandler
raise ImportError('%s has no attribute %s' % (handler, name))
ImportError: <module 'mapreduce.main' from '/base/data/home/apps/s~xxxxxxonline/2.361692533819432574/mapreduce/main.pyc'> has no attribute app
I found one SO reference ( How to migrate my app.yaml to 2.7? ) but as you can see from my yaml, I think I've tried all combinations to try to get it to resolve. Thanks.
This worked for me, but I'm still on a pretty old version of the SDK, I don't know if they fixed this:
- url: /mapreduce(/.*)?
script: mapreduce.main.APP
login: admin

Running neo4j-Python code in Eclipse with Pydev under ArchLinux

so I installed neo4j on ArchLinux (AUR Link) and want to test it using python 3.2.
I am using python 3.2, Eclipse with Pydev.
I tried following code from the neo4j website, allthough I think it was still 2.7 python code and I tried to convert it to Python 3.2 code.
Here's the code:
import os
libpath = '/usr/share/java/neo4j'
os.environ['CLASSPATH'] = ';'.join( [ os.path.abspath(p) for p in
os.listdir(libpath)])
from neo4j import GraphDatabase
# Create a database
db = GraphDatabase('/home/USERNAME/.db/neo4j/HelloWorld')
# All write operations happen in a transaction
with db.transaction:
firstNode = db.node(name='Hello')
secondNode = db.node(name='world!')
# Create a relationship with type 'knows'
relationship = firstNode.knows(secondNode, name='graphy')
# Read operations can happen anywhere
message = ' '.join([firstNode['name'], relationship['name'], secondNode['name']])
print(message)
# Delete the data
with db.transaction:
firstNode.knows.single.delete()
firstNode.delete()
secondNode.delete()
# Always shut down your database when your application exits
db.shutdown()
But I get following error message:
Traceback (most recent call last):
File "/home/USERNAME/PATH/TO/src/neo4j-HelloWorld.py", line 12, in <module>
from neo4j import GraphDatabase
File "/usr/lib/python3.2/site-packages/neo4j_embedded-1.6-py3.2.egg/neo4j/__init__.py", line 29, in <module>
from neo4j.core import GraphDatabase, Direction, NotFoundException, BOTH, ANY, INCOMING, OUTGOING
File "/usr/lib/python3.2/site-packages/neo4j_embedded-1.6-py3.2.egg/neo4j/core.py", line 19, in <module>
from _backend import *
ImportError: No module named _backend
I just can't figure out what's wrong!
I tried to set the CLASSPATH as described here, but it doesn't change anything.
I would really appreciate any help!
Did you run the code through 2to3?
If not, I suggest you do.
I think the problem is that the relative import syntax changed in 3.x, see PEP328 for details.
e.g. the offending import in core.py should probably say from ._backend import *

Resources