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

Allow arc5gl user to be configured via ~/.arcgl_user file #4

Merged
merged 2 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Ska/arc5gl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import six
import pexpect
import os

# Should put in a watchdog timer to exit from arc5gl after a period of inactivity
import ska_helpers
Expand All @@ -18,16 +19,27 @@ def __init__(self, echo=False, timeout=100000):
prompt indicating command completion. Example::

arc5gl = Ska.arc5gl.Arc5gl()
arc5gl.send('obsid=8018')
arc5gl.send('get acis2{evt2}')
arc5gl.sendline('obsid=21151')
arc5gl.sendline('get acis2{evt2}')
del arc5gl # explicitly shut things down, good idea

If the file ``${HOME}/.arc5gl_user`` exists then the content will be taken
as the user name to pass to the ``arc5gl`` Perl application for authentication.
Otherwise the linux username will be used.

:param echo: echo arc5gl output (default=False)
:param timeout: wait for up to timeout seconds for response (default=100000)
"""
args = ['--stdin']

arc5gl_user_file = os.path.join(os.environ['HOME'], '.arc5gl_user')
if os.path.exists(arc5gl_user_file):
user = open(arc5gl_user_file).read().strip()
args = args + ['--user={}'.format(user)]

self.prompt = 'ARC5GL> '
spawn = pexpect.spawn if six.PY2 else pexpect.spawnu
self.arc5gl = spawn('/proj/sot/ska/bin/arc5gl', args=['--stdin'], timeout=timeout)
self.arc5gl = spawn('/proj/sot/ska/bin/arc5gl', args=args, timeout=timeout)
self.arc5gl.expect(self.prompt)
self.echo = echo
self.arc5gl.setecho(echo)
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from setuptools import setup

setup(name='Ska.arc5gl',
author = 'Tom Aldcroft',
author='Tom Aldcroft',
description='Use arc5gl to access the Chandra archive',
author_email = 'aldcroft@head.cfa.harvard.edu',
py_modules = ['Ska.arc5gl'],
author_email='taldcroft@cfa.harvard.edu',
py_modules=['Ska.arc5gl'],
use_scm_version=True,
setup_requires=['setuptools_scm', 'setuptools_scm_git_archive'],
zip_safe=False,
packages=['Ska'],
package_dir={'Ska' : 'Ska'},
package_dir={'Ska': 'Ska'},
package_data={}
)