How to create pyral configuration file in rally development? - python

I am trying to use python REST API to access the contents from Rally. In read me, they mentioned to use a configuration file for server name, user credentials, etc. Where can i create a configuration file and what are the contents that i need to put in that configuration file.
Please help me... Thanks.

To use a config file when running a program using pyral, use the --conf= argument syntax on the command line. Note that you do not need to specify the '.cfg' suffix portion of your configuration file name.
Also, pyral offers some fairly lenient syntax when specifying the --conf part. You can also use --config=... or --cfg=... or --rallyConfig=... in addition to the --conf=... syntax.
Within your Python script using pyral, you'll need to import rallySettings and have some code containing variable definitions, etc. Here's an example of the calling sequence that uses the contents of a config file named sample.conf:
python test_prog.py --conf=sample
sample.conf:
SERVER = rally1.rallydev.com
USER = your_Rally_user_name#your_company.com
PASSWORD = your_Rally_password
WORKSPACE = Your Rally Workspace
PROJECT = Your Rally Project

Related

Is there a django app that provides a file chooser for the files on the server?

I need a component that's a browser-based file browser, and I expect some django app to currently provide this. Is there such a thing?
The full story:
I'm building a django app that is used for testing. I want to use it to serve files (and strings, and etc.) and attach custom headers to it.
Currently, I have a model FileSource which has a single file_path field, which is of type django.db.models.FileField.
When creating a FileSource from the admin, the user has a nice file upload dialog, and when saving, the file he chose, is saved on the server (in a really weird location, inside the directory where django is installed, or something weird like that, because i didn't customize the storage, nor will it help me in any way)
My problem: I only want to use the file dialog for the user to select a full path on the server. The file that the user chose must be only referenced, not copied (like currently), and it must reside on the server.
The server must thus be able to list the files it has, so i basically need a little browser-based file-browser.
At that point, I expect to be able to save a full path in my DB, and then I'll be able to access that file and serve it (together with whatever custom headers the user will chose from my app).
Currently, as you might know, the browsers always lie about the full path of the file. Chromium appends "C:\fakepath" to the file name, so I need support of the backend to accomplish this.
Also, I checked out django-filebrowser and django-filer and from what I understood, they weren't built for this. If I'm wrong, a little assistence in configuring them would be awesome.
You can use a FilePathField for that. It won't upload a file, but rather allow you to choose a pre-existing file. A caveat is that you can only use one directory. If you need multiple directories, then you'd need do go with something like django-filer.

Ubuntu encrypted home directory | Errno 36 File Name too long

Working on a python scraper/spider and encountered a URL that exceeds the char limit with the titled IOError. Using httplib2 and when I attempt to retrieve the URL I receive a file name too long error. I prefer to have all of my projects within the home directory since I am using Dropbox. Anyway around this issue or should I just setup my working directory outside of home?
You are probably hitting limitation of the encrypted file system, which allows up to 143 chars in file name.
Here is the bug:
https://bugs.launchpad.net/ecryptfs/+bug/344878
The solution for now is to use any other directory outside your encrypted home directory. To double check this:
mount | grep ecryptfs
and see if your home dir is listed.
If that's the case either use some other dir above home, or create a new home directory without using encryption.
The fact that the filename that's too long starts with '.cache/www.example.com' explains the problem.
httplib2 optionally caches requests that you make. You've enabled caching, and you've given it .cache as the cache directory.
The easy solution is to put the cache directory somewhere else.
Without seeing your code, it's impossible to tell you how to fix it. But it should be trivial. The documentation for FileCache shows that it takes a dir_name as the first parameter.
Or, alternatively, you can pass a safe function that lets you generate a filename from the URI, overriding the default. That would allow you to generate filenames that fit within the 144-character limit for Ubuntu encrypted fs.
Or, alternatively, you can create your own object with the same interface as FileCache and pass that to the Http object to use as a cache. For example, you could use tempfile to create random filenames, and store a mapping of URLs to filenames in an anydbm or sqlite3 database.
A final alternative is to just turn off caching, of course.
As you apparently have passed '.cache' to the httplib.Http constructor, you should change this to something more appropriate or disable the cache.

writing my first Trac macro

Ok, I've looked all over, and I think I'm doing this right, but I'm not getting any results. Is there anyone out there who's written Trac macros that can guide me through the first steps? Here's what I've written:
from trac.wiki.macros import WikiMacroBase
from genshi.builder import tag
class MyMacro(WikiMacroBase):
"""Proof of concept"""
revision = "$Rev$"
url = "$URL$"
def expand_macro(self, formatter, name, args):
return tag.b("Hello world.")
I've saved it as a .py file and put it in my Trac project's /plugins directory. Do I need to restart apache? Am I correct in expecting [[MyMacro]] to output a Hello world. on the page?
When creating macros using that format, Trac expects your class to be named "<name>Macro". For example, if you wanted a macro named JustASample, you would name the class JustASampleMacro. Since you named your class MyMacro, Trac thinks that you want your macro to be named My. Try using [[My]] on a wiki page and see if you get the output you're expecting.
After you copy the file into the plugins directory, you will indeed want to restart the web server. Before doing so, delete any .pyc files that were created for your plugin. Also, ensure that the file is readable by the account under which the web server runs.

Can I set the permissions of the contents of a dynamically generated zip file in Google App Engine?

In my app engine script (using the Python API), I'm using this code to dynamically generate zip files and serve them back to the user. When I download and extract the generated zip file and I'm running OS X, the permissions of each file extracted from the archive is 0, forcing me to chmod them. I'd rather not have my users have to do the same. Is there a way to fix this?
Yup, see the docs for the Python zipfile module. Specifically, the signature of the writestr method, which is:
ZipFile.writestr(zinfo_or_arcname,
bytes[, compress_type])
The first argument can be the filename, or a ZipInfo object, which allows you to specify information about the file to be stored. I believe the relevant field to set to change the permissions of the file is the external_attr, but some experimentation reading existing zip files may be required to determine this.

Where should the python babel mapping configuration file be placed or named for standalone script?

I am currently trying to use Babel to generate a set of static html pages in different languages using Jinja2 within a simple script (not as part of a web app)
I am at the point where I need to extract the messages for translation and I know that I am supposed to modify the Babel mapping configuration file to understand Jinja2 templates.Since I am using the commandline tool, I assume I need to create the mapping file myself.
However, I can't seem to find in the documentation what the mapping configuration file should be named and where it should be placed. All I know is that I need to place the following:
[jinja2: **/templates/**.html]
encoding = utf-8
into the mapping file according to the Jinja2 documentation. Has anyone done something similar or know what the mapping configuration file should be? Thanks!
You can specify the location of the configuration file with -c <filename>.
Mapping file location is read from setup.cfg file (generated by Distutils), in the section "extract_messages". In this section you must add setting named mapping_file, which should point to Your mapping file.
Example:
This tells Babel to look for mapping file named message-extraction.ini in package directory.
[extract_messages]
# some default options
# ..
mapping_file = message-extraction.ini
You can specify the path to the mapping configuration file for extract_messages using -F. For example, my mapping configuration is in babel.cfg, located at the root of my project. When extracting messages, I run:
pybabel extract -F babel.cfg ...

Categories

Resources