In [2]:
!pip install tinydb


Collecting tinydb
  Downloading tinydb-3.2.0.zip
Building wheels for collected packages: tinydb
  Running setup.py bdist_wheel for tinydb ... - \ done
  Stored in directory: /home/stephan/.cache/pip/wheels/b6/13/71/eb1895f83cbe0eafad9f9da0a348b81b46a666b1fd3f4c5c3c
Successfully built tinydb
Installing collected packages: tinydb
Successfully installed tinydb-3.2.0

In [1]:
import sys

sys.path.append('/home/stephan/Repos/ENES-EUDAT/submission_forms')
from dkrz_forms import rt_handler


.dkrz_forms myconfig imported
Settings from ~/.dkrz_forms imported

In [4]:



Settings from ~/.dkrz_forms imported

In [5]:
myt = rt_handler.get_tracker()


---------------------------------------------------------------------------
ConnectionError                           Traceback (most recent call last)
<ipython-input-5-26ce77380644> in <module>()
----> 1 myt = rt_handler.get_tracker()

/home/stephan/Repos/ENES-EUDAT/submission_forms/dkrz_forms/rt_handler.pyc in get_tracker()
     81 def get_tracker():
     82     tracker = rt.Rt('https://dm-rt.dkrz.de/REST/1.0/','kindermann',rt_pwd)
---> 83     tracker.login()
     84     return tracker
     85 

/home/stephan/.conda/envs/generic1/lib/python2.7/site-packages/rt.pyc in login(self, login, password)
    327             self.login_result = self.__get_status_code(self.__request('',
    328                                                                       post_data=login_data,
--> 329                                                                       without_login=True)) == 200
    330         except AuthorizationError:
    331             # This happens when HTTP Basic or Digest authentication fails, but

/home/stephan/.conda/envs/generic1/lib/python2.7/site-packages/rt.pyc in __request(self, selector, get_params, post_data, files, without_login, text_response)
    252             return result
    253         except requests.exceptions.ConnectionError as e:
--> 254             raise ConnectionError("Connection error", e)
    255 
    256     def __get_status_code(self, msg):

ConnectionError: Connection error (Caused by ConnectionError(MaxRetryError("HTTPSConnectionPool(host='dm-rt.dkrz.de', port=443): Max retries exceeded with url: /REST/1.0/ (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fd00e2b6ad0>: Failed to establish a new connection: [Errno 101] Network is unreachable',))",),))

In [4]:



True

In [6]:
info_db =rt_handler.get_info_db(rt_handler.info_db_path)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-e053f012606b> in <module>()
----> 1 info_db =rt_handler.get_info_db(rt_handler.info_db_path)

AttributeError: 'module' object has no attribute 'info_db_path'

In [11]:
results = rt_handler.db_get_name(info_db,'Kindermann')

vis_results = rt_handler.summary_html(results)

In [12]:
from IPython.core.display import HTML

HTML(vis_results)


Out[12]:
form namekeywordtimestampmodel / expstatus
Kindermann_tst2tst22016-04-26 15:51:41.445454MPI-Mstored
Kindermann_tst2.ipynbtst22016-04-26 14:44:23.696508[u'stored']

In [5]:
res = tracker.search(Queue='CORDEX', Status='open')


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-fb41024c25f4> in <module>()
----> 1 res = tracker.search(Queue='CORDEX', Status='open')

NameError: name 'tracker' is not defined

In [ ]:
rest = tracker.search(Queue='TestQueue')

In [ ]:
print rest

In [ ]:
?tracker.create_ticket

In [ ]:
import ConfigParser
import io
config = ConfigParser.ConfigParser(allow_no_value=True)

myticket = tracker.get_history(22950)

message = myticket[-1]['Content']
print message


config.readfp(io.StringIO(message))

config.sections()

In [ ]:
message = u"""

# comment
[section1]
aber: test

[section2]
b = 3

comment: lasjflasjf
      lasakljflasfj

"""
config.readfp(io.StringIO(message))

config.sections()

print config.get('section2','comment')

In [ ]:
val = config.get('test','test1')
print val

In [ ]:
myticket = tracker.get_history(22372)
print myticket[-1]['Content']

In [ ]:


In [ ]:
mytext = r"""kkkkkk  nnnn 
    1111
    2222
    3333
"""


print mytext

tracker.create_ticket(Queue="TestQueue", Subject="configparser test", 
                      Text=mytext,
                      Requestors="test-data-submitter@test.de",
                      Owner=u"kindermann")

In [ ]:
myticket = tracker.get_ticket(22949)
#print myticket
print tracker.get_history(22949)
print myticket.keys()
myatts = tracker.get_attachments(22949)
print myatts

In [ ]:


In [ ]:
tracker.comment(22252, text=""" upgedatet, ticket id \n === { "var1" : 22252, "var2" : 'test2' }\n  """)

In [ ]:
tracker.edit_ticket(22252, Owner=u"kindermann", Subject = "updated - test --aa-- {b,b} ## [c,d]")

In [ ]:
tracker.edit_ticket(22252, Requestors= [u'stephan.kindermann@gmail.com',u'snkinder@freenet.de'])

In [ ]:
tracker.comment(22252, text=u' es geht um a')

In [ ]:
tracker.reply(22252, text=u'Antwort zurück ...')

In [ ]:
?tracker.reply

In [ ]:
my_file = open("testfile.txt")

In [ ]:
tracker.reply(22252,text=u'nun mit Anhang',files=[('tst.txt',my_file)])

In [ ]:
tracker.get_attachments(22252)

In [ ]:
#attachment = tracker.get_attachment_content(22252,140183)
attachment = tracker.get_attachment_content(22252,140170)

In [ ]:
print attachment

In [ ]:
tracker.create_ticket(Queue="CORDEX", Subject="tool generated Test-Ticket through REST API: please ignore", Priority= 10,Owner="kindermann")

In [ ]:
tracker.edit_ticket(22080,Status="open")

In [ ]:
tracker.edit_ticket(22080,Status="rejected")

In [ ]:
tracker.edit_ticket(22080,Status="open",Subject="ticket re-opened")

In [ ]:
tracker.reply(22080,text="test answer")

In [ ]:
my_file = open("testfile.txt")

In [ ]:
ret = tracker.comment(22080,text="comment text",files=[("testfile.txt",my_file)])

In [ ]:
print ret

In [ ]:
tracker.create_ticket(Queue="CORDEX", Subject="test json CORDEX data submission: ")

In [ ]:
tst = tracker.get_attachment(22080,u'139196')

In [ ]:
print tst

In [ ]:
tracker.get_attachments(22080)

In [ ]:
try:
  from myconfig import cordex_directory
  from myconfig import rt_pwd
  print "Settings from ~/.dkrz_forms imported"
except ImportError:
  print "Info: myconfig not found - taking default config "
  from config import cordex_directory
    
def get_tracker():
    tracker = rt.Rt('https://dm-rt.dkrz.de/REST/1.0/','kindermann',rt_pwd)
    tracker.login()
    return tracker

In [ ]:
myt = get_tracker()

In [ ]:
print myt.get_history(22372)[-1]['Content']

In [ ]: