[ECODP-dev] Problems with paster commands ?

John Glover john.glover at okfn.org
Mon Jun 17 09:02:38 UTC 2013


Hi Dimitrios,

We did not provide those bash scripts so you will have to look at problems
with them on your side. If you have a CKAN paster command or API command
that is not behaving as expected then I will be happy to look at it if you
provide an example.

In that error message you seem to be getting a NotAuthorized error. If this
is using a API command, you need to double check that you are using a valid
API key for a sysadmin user.

To list sysadmins:
/applications/ecodp/users/ecodp/ckan/ecportal/bin/paster --plugin=ckan
sysadmin list -c /applications/ecodp/users/ecodp/ckan/conf/ecportal.ini

To view their API keys:
/applications/ecodp/users/ecodp/ckan/ecportal/bin/paster --plugin=ckan user
<user ID> -c /applications/ecodp/users/ecodp/ckan/conf/ecportal.ini

Regards,
John


On 14 June 2013 10:53, Dimitrios Mexis <dimitrios.mexis at tenforce.com> wrote:

> Running the following commands like :
> ./ckan_create_publ_user.sh mexis acp b850f583-0639-4521-9eae-3d6da8d52b5e
> http://*192.168.39.102*
>
> OR
>
> ./ckan_create_publ_user.sh mexis acp 6812eaea-404a-4c72-a6de-8f45ab4d7e95
> http://*192.168.33.87*
>
> where 102 is the Test machine you have been provided, and 87 is our test
> machine.
> *87 has migrated data from 1.7 version. while 102 is 1.8.*
>
> *produce both the error [below we copied the script ] :*
> *Traceback (most recent call last):*
> *  File "/applications/ecodp/users/ecodp/ckan/ecportal/bin/paster", line
> 9, in <module>*
> *    load_entry_point('PasteScript==1.7.5', 'console_scripts', 'paster')()
> *
> *  File
> "/applications/ecodp/users/ecodp/ckan/ecportal/lib/python2.6/site-packages/paste/script/command.py",
> line 104, in run*
> *    invoke(command, command_name, options, args[1:])*
> *  File
> "/applications/ecodp/users/ecodp/ckan/ecportal/lib/python2.6/site-packages/paste/script/command.py",
> line 143, in invoke*
> *    exit_code = runner.run(args)*
> *  File
> "/applications/ecodp/users/ecodp/ckan/ecportal/lib/python2.6/site-packages/paste/script/command.py",
> line 238, in run*
> *    result = self.command()*
> *  File
> "/applications/ecodp/users/ecodp/ckan/ecportal/src/ckan/ckan/lib/cli.py",
> line 595, in command*
> *    self.add()*
> *  File
> "/applications/ecodp/users/ecodp/ckan/ecportal/src/ckan/ckan/lib/cli.py",
> line 704, in add*
> *    user_dict = logic.get_action('user_create')(context, data_dict)*
> *  File
> "/applications/ecodp/users/ecodp/ckan/ecportal/src/ckanext-ecportal-release-v1.8.1/ckanext/ecportal/logic.py",
> line 381, in user_create*
> *    return logic.action.create.user_create(new_context, data_dict)*
> *  File
> "/applications/ecodp/users/ecodp/ckan/ecportal/src/ckan/ckan/logic/action/create.py",
> line 673, in user_create*
> *    _check_access('user_create', context, data_dict)*
> *  File
> "/applications/ecodp/users/ecodp/ckan/ecportal/src/ckan/ckan/logic/__init__.py",
> line 210, in check_access*
> *    raise NotAuthorized(msg)*
> *ckan.logic.NotAuthorized: You are not authorized to create new users*
> *  % Total    % Received % Xferd  Average Speed   Time    Time     Time
>  Current*
> *                                 Dload  Upload   Total   Spent    Left
>  Speed*
> *118   988  109   988    0    82    959     79  0:00:01  0:00:01 --:--:--
>   881*
> *{"help": "Make an object (e.g. a user, dataset or group) a member of a
> group.\n\n If the object is already a member of the group then the capacity
> of the\n membership will be updated.\n\n You must be authorized to edit the
> group.\n\n :param id: the id or name of the group to add the object to\n
> :type id: string\n :param object: the id or name of the object to add\n
> :type object: string\n :param object_type: the type of the object being
> added, e.g. ``'package'``\n or ``'user'``\n :type object_type: string\n
> :param capacity: the capacity of the membership\n :type capacity:
> string\n\n :returns: the newly created (or updated) membership\n :rtype:
> dictionary\n\n ", "success": true, "result": {"capacity": "editor",
> "state": "active", "table_id": "User: None", "table_name": "user",
> "revision_id": "df664eec-fa69-475b-9101-f832fe205ee4", "group_id":
> "d8701996-6f54-4d50-afeb-4a797f8005a0", "id":
> "a9f43462-5804-4a2f-8d1f-0288a0b37fbc"}}*
>
>
>
> *The relevant script is :*
> *#!/bin/bash*
> *
> *
> *if [ $# -lt 4 ] ; then*
> *   echo "4 arguments are mandatory"*
> *   echo "arg1 the username"*
> *   echo "arg2 the publishers acronym"*
> *   echo "arg3 the sysadmin api key"*
> *   echo "arg4 the frontend prefix in the form http://\$FRONTEND"*
> *   exit*
> *   fi*
> *
> *
> *source ./paster.sh*
> *
> *
> *
> *
> *# arg1 is username*
> *#      password will be prompted*
> *# arg2 is publisher acronym, lower cased e.g. cnect*
> *# arg3 is the sysadmin api key*
> *# arg4 is the frontend hostname/ip-address prefix of the form http://
> $FRONTEND*
> *
> *
> *# create a new user*
> *
> *
> *# Run the paster command, referencing the .ini file*
> *paster --plugin=ckan user add $1 -c $CKAN_INI*
> *USERDESC=`paster --plugin=ckan user $1 -c $CKAN_INI`*
> *
> *
> *# alternative 1: insert via updating the group information*
> *#GroupDef=`curl -X POST "$4/data/api/3/action/group_show" -d "{\"id\":
> \"$2\"}" -H "Authorization: $3"`*
> *#GroupDef2=`echo $GroupDef | sed -e "s/^.*result...{/{/" | sed -e
> "s/}$//" `*
> *#echo $GroupDef*
> *
> *
> *#GroupDef3=`echo $GroupDef2 | sed -e "s/users\": \[/users\":
> \[{\"name\": \"$1\", \"capacity\": \"editor\"},/" `*
> *#echo $GroupDef3*
> *
> *
> *#GroupUpdate=`curl -X POST "$4/data/api/3/action/group_update" -d
> "$GroupDef3" -H "Authorization: $3"`*
> *
> *
> *
> *
> *# alternative 2: insert via a specific call*
> *UserID=` echo $USERDESC | sed -e "s/ name.*//" | sed -e "s/^.*id=//" `*
> *GroupUpdate2=`curl -X POST "$4/data/api/3/action/member_create" -d
> "{\"id\": \"$2\", \"object\": \"$UserID\", \"object_type\": \"user\",
> \"capacity\": \"editor*
> *\"}" -H "Authorization: $3"`*
> *echo $GroupUpdate2*
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.okfn.org/mailman/private/ecodp-dev/attachments/20130617/24181034/attachment.html>


More information about the ecodp-dev mailing list