Cant run Python Views on Couchdb - python
i started using couchdb with python-couchdb recently. The problem is when i use futon run my views written in python i get the following error message:
Error: os_process_error
{exit_status,1}
even for the default view it crashes.
def fun(doc):
yield None, doc
i haven't yet found much information regarding this issue so at this point im really lost. This is the log i get from couchdb:
{<0.3907.0>,crash_report,
[[{initial_call,{couch_file,init,['Argument__1']}},
{pid,<0.3907.0>},
{registered_name,[]},
{error_info,
{exit,
{os_process_error,{exit_status,1}},
[{gen_server,terminate,6},{proc_lib,init_p_do_apply,3}]}},
{ancestors,
[<0.3906.0>,couch_view,couch_secondary_services,couch_server_sup,
<0.33.0>]},
{messages,[]},
{links,[#Port<0.1483>,<0.3910.0>]},
{dictionary,[]},
{trap_exit,true},
{status,running},
{heap_size,377},
{stack_size,24},
{reductions,1423}],
[{neighbour,
[{pid,<0.3910.0>},
{registered_name,[]},
{initial_call,{couch_ref_counter,init,['Argument__1']}},
{current_function,{gen_server,loop,6}},
{ancestors,
[<0.3906.0>,couch_view,couch_secondary_services,
couch_server_sup,<0.33.0>]},
{messages,[]},
{links,[#Port<0.1483>,<0.3910.0>]},
{dictionary,[]},
{trap_exit,true},
{status,running},
{heap_size,377},
{stack_size,24},
{reductions,1423}],
[{neighbour,
[{pid,<0.3910.0>},
{registered_name,[]},
{initial_call,{couch_ref_counter,init,['Argument__1']}},
{current_function,{gen_server,loop,6}},
{ancestors,
[<0.3906.0>,couch_view,couch_secondary_services,
couch_server_sup,<0.33.0>]},
{messages,
[{'DOWN',#Ref<0.0.0.16475>,process,<0.3906.0>,
{os_process_error,{exit_status,1}}}]},
{links,[<0.3907.0>]},
{dictionary,[]},
{trap_exit,false},
{status,runnable},
{heap_size,233},
{stack_size,9},
{reductions,47}]}]]}}
Im running this on Ubuntu 10.04, with Django, couchdb and python-couchdb. The views on javascript works fine.
For couchdb-python query server exit status 1 means some error that.
What version of couchdb/couchdb-python you're uses?
Whats output will be if you run couchpy (or /usr/local/bin/couchpy or whatever you have setted in query_servers section for python key) directly from command line? Example as it should be:
$
~ $ couchpy
["reset"]
true
["add_fun", "def fun(doc): yield None, None"]
true
["map_doc", {}]
[[[null, null]]]
If p.2 works fine, try to enable CouchDB debug log level to trace query server commands and notice when it falls. If you're sure that this is a python query server bug, please write some story about it. Thanks(:
P.S. I hope that you have setup python query server correctly, but double things check never was useless(;
Related
Django error: column does not exist but I have no control over that table?
I have made a few changes in the code, but nothing that changes the model or adds new things to the database. When I run on my computer it works fine, but when I try to build the docker image and run it gives me this error: Traceback (most recent call last): File "/home/go/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 82, in _execute return self.cursor.execute(sql) psycopg2.errors.UndefinedColumn: column c.relispartition does not exist LINE 3: CASE WHEN c.relispartition THEN 'p' WHEN c.relki... ^ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/manage.py", line 35, in <module> main() File "/app/manage.py", line 31, in main execute_from_command_line(sys.argv) File "/home/go/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/home/go/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/go/.local/lib/python3.9/site-packages/django/core/management/base.py", line 373, in run_from_argv self.execute(*args, **cmd_options) File "/home/go/.local/lib/python3.9/site-packages/django/core/management/base.py", line 417, in execute output = self.handle(*args, **options) File "/home/go/.local/lib/python3.9/site-packages/django/core/management/base.py", line 90, in wrapped res = handle_func(*args, **kwargs) File "/home/go/.local/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 92, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "/home/go/.local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "/home/go/.local/lib/python3.9/site-packages/django/db/migrations/loader.py", line 53, in __init__ self.build_graph() File "/home/go/.local/lib/python3.9/site-packages/django/db/migrations/loader.py", line 223, in build_graph self.applied_migrations = recorder.applied_migrations() File "/home/go/.local/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 77, in applied_migrations if self.has_table(): File "/home/go/.local/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 56, in has_table tables = self.connection.introspection.table_names(cursor) File "/home/go/.local/lib/python3.9/site-packages/django/db/backends/base/introspection.py", line 52, in table_names return get_names(cursor) File "/home/go/.local/lib/python3.9/site-packages/django/db/backends/base/introspection.py", line 47, in get_names return sorted(ti.name for ti in self.get_table_list(cursor) File "/home/go/.local/lib/python3.9/site-packages/django/db/backends/postgresql/introspection.py", line 49, in get_table_list cursor.execute(""" File "/home/go/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 98, in execute return super().execute(sql, params) File "/home/go/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/home/go/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers return executor(sql, params, many, context) File "/home/go/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/home/go/.local/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/home/go/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 82, in _execute return self.cursor.execute(sql) django.db.utils.ProgrammingError: column c.relispartition does not exist LINE 3: CASE WHEN c.relispartition THEN 'p' WHEN c.relki... ^ For me this is strange because I have no control over what this table does. When I run makemigrations and migrate it tells me that nothing has changed. If I run the docker image against a local postgres database it works and there is no such error, this error is happening on production database. I have tried the solutions to similar problems here on stackoverflow but nothing worked. It seems like the only solution is to create a new database...
AWS Personalize throws bad param error using context={...}
I am working with AWS Personalize and the Python SDK (boto3). All goes well until I try to include the context param in the request. While everything works as expected within the Personalize > Campaigns UI for testing the results, when I try to use the following code: response = personalizeRt.get_recommendations( campaignArn = 'arn:aws:personalize:XXXXXXXXXX:campaign/interactions-meta', userId = '43f0c7fd-4d89-4752-9c88-2fe5bf7ac830', context={ 'GENRES' : '42' } ) I get the following error: Unknown parameter in input: "context", must be one of: campaignArn, itemId, userId, numResults Has anyone else seen this error? And if so, how did you resolve it. Thanks in advance.
Seems the issue is the version of boto3/botocore within Pycharm. If I run the same code on the command line, all works as expected. In Pycharm go to Preferences > Project Interpreter. and you can update boto3 there.
win32com.client.Dispatch works, win32com.client.GetActiveObject doesnt
Im using python 2.7.9, windows 7... The overall goal: Have another application access our custom com server (already running at this point) and send it a message to be displayed. Obviously, there needs to be a single server, multiple clients. Im trying to use some custom code as a com server. The class was created as: class StatusServerClass: _public_methods_ = ... _reg_progid_ = "CseStatusServerLib.CseStatusServer" _reg_verprogid_ = "CseStatusServerLib.CseStatusServer" _reg_progid_ = "CseStatusServerLib.CseStatusServer" _reg_clsid_ = "{<GUID here>}" _reg_desc_ = 'CSE Status Server' _typelib_guid_ = "{<typelib GUID here>}" _typelib_version_ = 1, 0 # Version 1.0 _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER _reg_threading_ = "Apartment" # Not used? def __init__..... and registered using: win32com.server.register.UseCommandLine(StatusServerClass) I can see it in regedit and as far as i know, it looks ok. The GUID is right, name is right. Now when i go to use it, this works just fine: self.StatusClient = Dispatch('CseStatusServerLib.CseStatusServer') but when i want to attach to a running instance from another exe (or even another python window for debug) using: win32com.client.GetActiveObject("CseStatusServerLib.CseStatusServer") it just gives me: dispatch = pythoncom.GetActiveObject(resultCLSID) com_error: (-2147221021, 'Operation unavailable', None, None) Tells me that its not registered? Ive tried using the GUID, Ive tried using pythoncom.GetObject with both the ID and the GUID... no luck. Ive tried comtypes package and get the same thing. Any ideas on what im doing wrong? Why does Dispatch find it by name, but GetActiveObject gets mad? Seems that Dispatch working by name would suggest that the registering worked? What else can i verify in the regedit? thanks!!! UPDATED 6/6/2016 In case you haven't realized yet, I know very little about this. But I have read that for win32com.client.GetActiveObject() to work, the server needs to be in the "running object table"... and its not. So, I found some more example code that i used to register the class this way: import win32com.server.util wrapped = win32com.server.util.wrap(StatusServerClass) flags = pythoncom.REGCLS_MULTIPLEUSE|pythoncom.REGCLS_SUSPENDED handle = pythoncom.RegisterActiveObject(wrapped, StatusServerClass._reg_clsid_,flags) and that does allow the server to show in the running object table, and i can get this: testSW = win32com.client.GetActiveObject("CseStatusServerLib.CseStatusServer") to return without error. So now, I can use Dispatch or GetActiveObject just fine in python, pythonWin, and even interact with the server in Excel/VB <-> python and it appears to share namespsace. BUT... I still cant get this IE-based third party app to use the existing server... even with GetActiveObject. Always wants to create new instance and use its own namespace... not good Is there something with IE or Chrome that would prevent the existing server from being used? Again, it works fine in Excel/VB. The application is supposed to execute "python myscript.py" (which works fine in idle, pythonwin and cmdline), but doesnt execute the com server stuff when called from IE/Chrome App (although other python functions like file writing work just fine). Also, seeing as how i know very little about this, by all means, suggest a better way of doing this: starting a server in python as a singleton and then accessing it from another application. thanks!!
ipython-cypher in Python: cypher.run.Connection object parameter
I'm trying to use ipython-cypher to run Neo4j Cypher queries (and return a Pandas dataframe) in a Python program. I have no trouble forming a connection and running a query when using IPython Notebook, but when I try to run the same query outside of IPython, as per the documentation: http://ipython-cypher.readthedocs.org/en/latest/introduction.html#usage-out-of-ipython import cypher results = cypher.run("MATCH (n)--(m) RETURN n.username, count(m) as neighbors", "http://XXX.XXX.X.XXX:xxxx") I get the following error: neo4jrestclient.exceptions.StatusException: Code [401]: Unauthorized. No permission -- see authorization schemes. Authorization Required and Format: (http|https)://username:password#hostname:port/db/name, or one of dict_keys([]) Now, I was just guessing that that was how I should enter a Connection object as the last parameter, because I couldn't find any additional documentation explaining how to connect to a remote host using Python, and in IPython, I am able to do: %load_ext cypher results = %cypher http://XXX.XXX.X.XXX:xxxx MATCH (n)--(m) RETURN n.username, count(m) as neighbors Any insight would be greatly appreciated. Thank you.
The documentation has a section for the API. When used outside of IPython and in need to connect to a different host, just using the parameter conn and passing a string should work. import cypher results = cypher.run("MATCH (n)--(m) RETURN n.username, count(m) as neighbors", conn="http://XXX.XXX.X.XXX:xxxx") But also consider that with the new authentication support in Neo4j 2.2, you need to set the new password before connecting from ipython-cypher. I will fix this as soon as I implement the forcing password change mechanism in neo4jrestclient, the library underneath.
How do I perform a "yum update" using the Yumbase Python module?
Edit: So apparantly my install wasn't working. This pointed me to a mailing list Here where I figured out which commands I was missing. I have the answer for the update below. Now that I think about it, it does make sense. I just wish they'd put this somewhere simple on the dev pages. yb = yum.YumBase() yb.conf.assumeyes = True yb.update(name='aws-cli') yb.buildTransaction() yb.processTransaction() I'm trying to perform an update using yumbase when a server first boots with my kickstart script. At the moment I have a rather crude python subprocess to do "yum update" and would like to make this better. I'm trying to hook into Yumbase, but the documentation is quite scarce. I have had a look at both the source code and documentation on this page: http://yum.baseurl.org/wiki/5MinuteExamples I've figured out how to list all packages but not the ones that need updating using an SO answer from 2008: Given an rpm package name, query the yum database for updates I've also figured out it's a very simple 3-line process to install a new package: yb = yum.YumBase() yb.conf.assumeyes = True yb.install(name='aws-cli') However the following doesn't work to "update" the package: yb = yum.YumBase() yb.conf.assumeyes = True yb.update(name='aws-cli') So what I need is: 1: A way to list the packages that need updating, much like "yum check-update" 2: Install the packages above using "yum update"
From what I can see in the yum code, it doesn't seem to be written to be used as a library. The code you gave is not the right way to do it, there's much else happening behind the scenes. Basically, as of yum-3.4.3, the process looks like this: ->yummain.__main__ <trap KeyboardInterrupt> ->yummain.user_main(sys.argv[1:], exit_code=True) <check YUM_PROF,YUM_PDB envvars, wrap the following into debugger/profiler if set> ->yummain.main(args) <set up locale, set up logging> -><create a YumBaseCli (child of YumBase & YumOutput)> <incl. fill a list field with YumCommand instances of known commands> ->cli.YumBaseCli.getOptionsConfig() <parse args into the YumBaseCli instance, includes initializing plugins> <obtain global yum lock> <check write permissions for current dir> ->cli.YumBaseCli.doCommands() <select a YumCommand from the list> ->YumCommand.needTs/needTsRemove if needed ->YumCommand.doCommand(self, self.basecmd, self.extcmds) <handle errors & set error code if any> 'Resolving Dependencies' ->cli.YumBaseCli.buildTransaction() <check for an unfinished transaction> <resolve deps using the info written by the YumCommand into the object> <honor clean_requirements_on_remove, protected_packages, protected_multilib, perform some checks> <handle errors & set error code if any> 'Dependencies Resolved' ->cli.YumBaseCli.doTransaction() <download, transaction check, transaction test, transaction using the info in the object> <handle errors & set error code if any> 'Complete!' <release global yum lock> sys.exit(error_code) As you can see, the main working sequence is embedded directly into main so you can only replicate this logic in-process by running it directly: yummain.main(<sequence of cmdline arguments>) Which is just the same as running a separate process minus process isolation.