pydigdrop

pydigdrop

This Python script uses Digital Ocean api services. Importing the features from the Python module digitalocean. Data is pulled and edited.

Here is a list of features and ideas.

  • Returns user server list.
  • Returns info about servers - name/ip/location/status/distro id/distro.
  • shutdown, make snapshot, startup all servers (or just one!)
  • save info off as json/html
  • Plans start as little as $5.00 a month. Servers are charged per the hour. Digital Ocean

    
    
    In [1]:
    import os
    import json
    import digitalocean
    
    
    
    In [9]:
    opcli = open('passwd', 'r')
    opapi = open('passap', 'r')
    
    
    
    In [7]:
    digclip = str(opcli.read())
    
    
    
    In [10]:
    digcli = str(opapi.read())
    
    
    
    In [6]:
    manager = digitalocean.Manager(client_id = digcli, api_key = apikey)
    
    
    
    In [7]:
    mydrop = manager.get_all_droplets()
    
    
    
    In [8]:
    print mydrop
    
    
    
    
    [<digitalocean.Droplet.Droplet object at 0x31259d0>, <digitalocean.Droplet.Droplet object at 0x3125a10>, <digitalocean.Droplet.Droplet object at 0x3125a90>]
    
    
    
    In [9]:
    dropo = mydrop[0]
    
    
    
    In [10]:
    print dropo
    
    
    
    
    <digitalocean.Droplet.Droplet object at 0x31259d0>
    
    
    
    In [11]:
    events = dropo.get_events()
    
    
    
    In [34]:
    for event in events:
        event.load()
        print event.percentage
    
    
    
    In [35]:
    servlis = []
    
    
    
    In [75]:
    meip.keys
    
    
    
    
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-75-018bfb339428> in <module>()
    ----> 1 meip.keys
    
    AttributeError: 'Droplet' object has no attribute 'keys'
    
    
    In [88]:
    for meip in mydrop:
        print meip.name
        servlis.append(meip.name)
        print meip.ip_address
        servlis.append(meip.ip_address)
        print meip.status
        servlis.append(meip.status)
        print meip.image_id
        servlis.append(meip.image_id)
        servlis.append('wcmckee')
        servlis.append(meip.region_id)
    
    
    
    
    wcmckee
    128.199.199.74
    active
    308287
    catgang
    188.226.209.162
    active
    3135725
    compohub
    107.170.136.184
    active
    3445812
    
    
    
    In [92]:
    servlis.sort()
    
    
    
    In [94]:
    fservlz = list(set(servlis))
    
    
    
    In [96]:
    fservlz.sort()
    
    
    
    In [97]:
    fservlz
    
    
    
    
    Out[97]:
    [4,
     5,
     6,
     308287,
     3135725,
     3445812,
     u'107.170.136.184',
     u'128.199.199.74',
     u'188.226.209.162',
     u'active',
     u'catgang',
     u'compohub',
     u'wcmckee']
    
    
    In [98]:
    from crontab import CronTab
    
    
    
    In [99]:
    syscrm = CronTab()
    
    
    
    In [111]:
    job = syscrm.new(command='cd learnpython; ipython notebook --profile=wcm')
    
    
    
    In [112]:
    job.every_reboot()
    
    
    
    
    Out[112]:
    True
    
    
    In [113]:
    job.enable()
    
    
    
    
    Out[113]:
    True
    
    
    In [117]:
    job.frequency_per_day()
    
    
    
    
    Out[117]:
    1440
    
    
    In [ ]:
    clisz = []
    
    
    
    In [129]:
    svex = ia.search_movie('game of thrones')
    
    
    
    In [175]:
    thrlis = []
    
    
    
    In [176]:
    for sc in svex:
        #print sc
        #print sc[u'title']
        #thrlis.append(sc[u'long imdb title'])
        #thrlis.append(sc.get_current_info)
        print sc.getID()
        thrlis.append(sc.getID())
    
    
    
    
    0944947
    2231444
    3391176
    2653342
    2653350
    2653340
    2972984
    3645842
    3131362
    2653338
    2653354
    3645808
    2653346
    2653356
    2143796
    2653352
    3030478
    2653344
    2667902
    2718250
    
    
    
    In [177]:
    mov = ia.get_movie(thrlis[0])
    
    
    
    In [179]:
    mov.guessLanguage()
    
    
    
    
    Out[179]:
    u'English'
    
    
    In [189]:
    cast = mov['cast'][0]
    
    
    
    In [192]:
    ia.update(cast)
    
    
    
    In [193]:
    cast[u'name']
    
    
    
    
    Out[193]:
    u'Peter Dinklage'
    
    
    In [196]:
    cast.notes
    
    
    
    
    Out[196]:
    u'(38 episodes, 2011-2014)'
    
    
    In [209]:
    cast.items()
    
    
    
    
    Out[209]:
    [(u'soundtrack tv',
      [<Movie id:0072562[http] title:_Saturday Night Live (2013)_>]),
     ('name', u'Peter Dinklage'),
     ('in development',
      [<Movie id:3510266[http] title:_The Chess Machine (????)_>,
       <Movie id:2386223[http] title:_Fellini Black and White (????)_>,
       <Movie id:2953180[http] title:_Hop Frog (????)_>]),
     ('self',
      [<Movie id:0115147[http] title:_The Daily Show with Jon Stewart (2003)_>,
       <Movie id:0081857[http] title:_Entertainment Tonight (2014)_>,
       <Movie id:2761236[http] title:_omg! Insider (2014)_>,
       <Movie id:3477194[http] title:_The 20th Annual Screen Actors Guild Awards (2014)_>,
       <Movie id:3170732[http] title:_The 65th Primetime Emmy Awards (2013)_>,
       <Movie id:2806252[http] title:_2013 MTV Movie Awards (2013)_>,
       <Movie id:2262378[http] title:_The 64th Primetime Emmy Awards (2012)_>,
       <Movie id:2125640[http] title:_The 69th Annual Golden Globe Awards (2012)_>,
       <Movie id:2972984[http] title:_Game of Thrones: You Win or You Die - Inside the HBO Series (2012)_>,
       <Movie id:2177699[http] title:_Scream Awards 2011 (2011)_>,
       <Movie id:2056718[http] title:_The 63rd Primetime Emmy Awards (2011)_>,
       <Movie id:1292039[http] title:_Starz Inside: Fantastic Flesh (2008)_>,
       <Movie id:0795174[http] title:_P.O.V. (2004)_>,
       <Movie id:0937105[http] title:_The Real Family of Jesus (2005)_>,
       <Movie id:0389591[http] title:_Celebrity Poker Showdown (2005)_>,
       <Movie id:0387199[http] title:_Entourage (2005)_>,
       <Movie id:0291604[http] title:_Dinner for Five (2004)_>,
       <Movie id:0449465[http] title:_The 2004 IFP/West Independent Spirit Awards (2004)_>,
       <Movie id:0103569[http] title:_The Tonight Show with Jay Leno (2003)_>,
       <Movie id:1249207[http] title:_CBS Cares (2000)_>,
       <Movie id:0459660[http] title:_Nobody Wants Your Film (2005)_>,
       <Movie id:0454782[http] title:_As Smart As They Are: The Author Project (2005)_>,
       <Movie id:2653342[http] title:_Game of Thrones: Season 2 - Character Profiles (2013)_>,
       <Movie id:2596270[http] title:_Ice Age Continental Drift: Through a Pirate's Spyglass: Voices Ahoy! (2012)_>,
       <Movie id:2653338[http] title:_Game of Thrones: Season 2 - How to Be an Extra (2012)_>,
       <Movie id:2653356[http] title:_Game of Thrones: Destinations of Season 2 (2012)_>,
       <Movie id:2653340[http] title:_Game of Thrones: Season 2 - Invitation to the Set (2012)_>,
       <Movie id:2667902[http] title:_Game of Thrones: Season 2 - In Production: Croatia (2012)_>,
       <Movie id:2653350[http] title:_Game of Thrones: Costumes (2011)_>,
       <Movie id:2653352[http] title:_Game of Thrones: Inside the Night's Watch (2011)_>]),
     ('mini biography',
      [u'Peter Dinklage was born in Morristown, New Jersey. In 1991, he received a degree in drama from Bennington College and began his career. He continues to work in the theatre with roles in "The Killing Act", "Imperfect Love", and "Richard III".Peter Dinklage received acclaim for his first film, Living in Oblivion (1995), where he played an actor frustrated with the limited and caricatured roles offered to dwarf actors. In 2003, he starred in The Station Agent (2003), written and directed by Thomas McCarthy. The movie received critical praise and Peter was nominated for best actor at the "Screen Actors Guild" and "Independent Spirit Awards". He played "Miles Finch", an acclaimed children\'s book author, in the comical 2003 film, Elf (2003). The English Death at a Funeral (2007) and American Death at a Funeral (2010), Penelope (2006) and The Chronicles of Narnia: Prince Caspian (2008) are a few more of his feature films.He had recurring appearances in such television shows as HBO\'s Entourage (2004) and ABC\'s Life As We Know It (2004). He played a larger role in the critically-acclaimed, yet short-lived CBS show, Threshold (2005). In 2011, he landed a primary role, as "Tyrion Lannister", on the HBO series, Game of Thrones (2011). Tyrion\'s wit made him a favorite character on the series. At the 2011 Primetime Emmy Awards, Peter Dinklage won an Emmy in the best supporting actor category for his role as "Tyrion Lannister".::Alex Gold']),
     ('actor',
      [<Movie id:2120120[http] title:_Pixels (2015)_>,
       <Movie id:3255124[http] title:_O' Lucky Day (2015)_>,
       <Movie id:3660078[http] title:_Taxi (2015)_>,
       <Movie id:1877832[http] title:_X-Men: Days of Future Past (2014)_>,
       <Movie id:2331047[http] title:_Rememory (I) (2013)_>,
       <Movie id:1294970[http] title:_The Angriest Man in Brooklyn (2014)_>,
       <Movie id:1864405[http] title:_Low Down (2014)_>,
       <Movie id:1545660[http] title:_Knights of Badassdom (2013)_>,
       <Movie id:1817081[http] title:_A Case of You (2013)_>,
       <Movie id:1667889[http] title:_Ice Age: Continental Drift (2012)_>,
       <Movie id:2115386[http] title:_Scrat's Continental Crack-Up: Part 2 (2011)_>,
       <Movie id:1440161[http] title:_A Little Bit of Heaven (2011)_>,
       <Movie id:1381413[http] title:_Pete Smalls Is Dead (2010)_>,
       <Movie id:1268970[http] title:_The Last Rites of Ransom Pride (2010)_>,
       <Movie id:1376709[http] title:_I Love You Too (2010)_>,
       <Movie id:1321509[http] title:_Death at a Funeral (2010)_>,
       <Movie id:1276105[http] title:_Saint John of Las Vegas (2009)_>,
       <Movie id:0499448[http] title:_The Chronicles of Narnia: Prince Caspian (2008)_>,
       <Movie id:0467110[http] title:_Underdog (2007)_>,
       <Movie id:0795368[http] title:_Death at a Funeral (2007)_>,
       <Movie id:0768167[http] title:_Ascension Day (2007)_>,
       <Movie id:0472160[http] title:_Penelope (2006)_>,
       <Movie id:0418835[http] title:_Little Fugitive (2006)_>,
       <Movie id:0419749[http] title:_Find Me Guilty (2006)_>,
       <Movie id:0756677[http] title:_The Limbo Room (2006)_>,
       <Movie id:0238992[http] title:_Fortunes (2005)_>,
       <Movie id:0431213[http] title:_Lassie (2005)_>,
       <Movie id:0476988[http] title:_Escape Artists (2005)_>,
       <Movie id:0401244[http] title:_The Baxter (2005)_>,
       <Movie id:0399215[http] title:_Jail Bait (2004)_>,
       <Movie id:0765496[http] title:_89 Seconds at Alcázar (2004)_>,
       <Movie id:0393836[http] title:_Surviving Eden (2004)_>,
       <Movie id:0319343[http] title:_Elf (2003)_>,
       <Movie id:0316768[http] title:_Tiptoes (2003)_>,
       <Movie id:0340377[http] title:_The Station Agent (2003)_>,
       <Movie id:0245479[http] title:_Just a Kiss (2002)_>,
       <Movie id:0276744[http] title:_13 Moons (2002)_>,
       <Movie id:0219822[http] title:_Human Nature (2001)_>,
       <Movie id:0244094[http] title:_Never Again (2001)_>,
       <Movie id:0138705[http] title:_Pigeonholed (1999)_>,
       <Movie id:0120813[http] title:_Safe Men (1998)_>,
       <Movie id:0115781[http] title:_Bullet (1996)_>,
       <Movie id:0113677[http] title:_Living in Oblivion (1995)_>,
       <Movie id:2249372[http] title:_Ice Age: Continental Drift - Arctic Games (2012)_>,
       <Movie id:1334439[http] title:_The Chronicles of Narnia: Prince Caspian (2008)_>,
       <Movie id:0944947[http] title:_Game of Thrones (2011)_>,
       <Movie id:0182576[http] title:_Family Guy (2014)_>,
       <Movie id:0072562[http] title:_Saturday Night Live (2013)_>,
       <Movie id:0496424[http] title:_30 Rock (2009)_>,
       <Movie id:0361217[http] title:_Nip/Tuck (2006)_>,
       <Movie id:0460686[http] title:_Threshold (2005)_>,
       <Movie id:0757354[http] title:_Ultra (2006)_>,
       <Movie id:0780624[http] title:_Testing Bob (2005)_>,
       <Movie id:0411004[http] title:_Life As We Know It (2005)_>,
       <Movie id:0366027[http] title:_I'm with Her (2004)_>,
       <Movie id:0197182[http] title:_Third Watch (2002)_>,
       <Movie id:0247135[http] title:_The $treet (2001)_>,
       <Movie id:0098904[http] title:_Seinfeld (1995)_>]),
     ('height', u'4\' 5" (1.35 m)'),
     ('birth notes', u'Morristown, New Jersey, USA'),
     (u'producer movie',
      [<Movie id:3255124[http] title:_O' Lucky Day (2015)_>,
       <Movie id:1381413[http] title:_Pete Smalls Is Dead (2010)_>]),
     ('headshot',
      u'http://ia.media-imdb.com/images/M/MV5BMTM1MTI5Mzc0MF5BMl5BanBnXkFtZTYwNzgzOTQz._V1_SY317_CR20,0,214,317_AL_.jpg'),
     (u'thanks movie', [<Movie id:0857191[http] title:_The Visitor (I) (2007)_>]),
     (u'stunts tv', [<Movie id:0118421[http] title:_Oz (2001)_>]),
     ('birth date', u'1969'),
     ('canonical name', u'Dinklage, Peter'),
     ('long imdb name', u'Peter Dinklage'),
     ('long imdb canonical name', u'Dinklage, Peter'),
     ('full-size headshot',
      u'http://ia.media-imdb.com/images/M/MV5BMTM1MTI5Mzc0MF5BMl5BanBnXkFtZTYwNzgzOTQz._V1_SY317_CR20,0,214,317_AL_.jpg')]
    
    
    In [211]:
    imghed = cast['headshot']
    
    
    
    In [212]:
    from IPython.display import Image
    
    
    
    In [214]:
    Image(imghed)
    
    
    
    
    Out[214]:
    
    
    In [205]:
    cast.summary()
    
    
    
    
    Out[205]:
    u'Person\n=====\nName: Dinklage, Peter\nBirth date: 1969 (Morristown, New Jersey, USA).\nBiography: Peter Dinklage was born in Morristown, New Jersey. In 1991, he received a degree in drama from Bennington College and began his career. He continues to work in the theatre with roles in "The Killing Act", "Imperfect Love", and "Richard III".Peter Dinklage received acclaim for his first film, Living in Oblivion (1995), where he played an actor frustrated with the limited and caricatured roles offered to dwarf actors. In 2003, he starred in The Station Agent (2003), written and directed by Thomas McCarthy. The movie received critical praise and Peter was nominated for best actor at the "Screen Actors Guild" and "Independent Spirit Awards". He played "Miles Finch", an acclaimed children\'s book author, in the comical 2003 film, Elf (2003). The English Death at a Funeral (2007) and American Death at a Funeral (2010), Penelope (2006) and The Chronicles of Narnia: Prince Caspian (2008) are a few more of his feature films.He had recurring appearances in such television shows as HBO\'s Entourage (2004) and ABC\'s Life As We Know It (2004). He played a larger role in the critically-acclaimed, yet short-lived CBS show, Threshold (2005). In 2011, he landed a primary role, as "Tyrion Lannister", on the HBO series, Game of Thrones (2011). Tyrion\'s wit made him a favorite character on the series. At the 2011 Primetime Emmy Awards, Peter Dinklage won an Emmy in the best supporting actor category for his role as "Tyrion Lannister".::Alex Gold\nLast movies acted: Pixels (2015); O\' Lucky Day (2015); Taxi (2015); X-Men: Days of Future Past (2014); Rememory (I) (2013).\n'
    
    
    In [200]:
    for caz in cast.current_info:
        print caz
    
    
    
    
    main
    filmography
    biography
    
    
    
    In [202]:
    cast.current_info[0]
    
    
    
    
    Out[202]:
    'main'
    
    
    In [183]:
    thrlis
    
    
    
    
    Out[183]:
    ['0944947',
     '2231444',
     '3391176',
     '2653342',
     '2653350',
     '2653340',
     '2972984',
     '3645842',
     '3131362',
     '2653338',
     '2653354',
     '3645808',
     '2653346',
     '2653356',
     '2143796',
     '2653352',
     '3030478',
     '2653344',
     '2667902',
     '2718250']
    
    
    In [160]:
    svex
    
    
    
    
    Out[160]:
    [<Movie id:0944947[http] title:_"Game of Thrones" (2011)_>,
     <Movie id:2231444[http] title:_Game of Thrones (2012) (VG)_>,
     <Movie id:3391176[http] title:_Game of Thrones (2014) (VG)_>,
     <Movie id:2653342[http] title:_Game of Thrones: Season 2 - Character Profiles (2013) (V)_>,
     <Movie id:2653350[http] title:_Game of Thrones: Costumes (2011) (V)_>,
     <Movie id:2653340[http] title:_Game of Thrones: Season 2 - Invitation to the Set (2012) (V)_>,
     <Movie id:2972984[http] title:_Game of Thrones: You Win or You Die - Inside the HBO Series (2012) (TV)_>,
     <Movie id:3645842[http] title:_Game of Thrones: The Politics of Power - A Look Back at Season 3 (2014) (TV)_>,
     <Movie id:3131362[http] title:_Sex Game of Thrones (2012) (V)_>,
     <Movie id:2653338[http] title:_Game of Thrones: Season 2 - How to Be an Extra (2012) (V)_>,
     <Movie id:2653354[http] title:_Making of Game of Thrones (2011) (V)_>,
     <Movie id:3645808[http] title:_Game of Thrones Ice and Fire: A Foreshadowing (2014) (TV)_>,
     <Movie id:2653346[http] title:_Game of Thrones: Season 2 - In Production, Iceland (2012) (V)_>,
     <Movie id:2653356[http] title:_Game of Thrones: Destinations of Season 2 (2012) (V)_>,
     <Movie id:2143796[http] title:_"Stupid for Game of Thrones" (2012)_>,
     <Movie id:2653352[http] title:_Game of Thrones: Inside the Night's Watch (2011) (V)_>,
     <Movie id:3030478[http] title:_Game of Thrones Ascent (2013) (VG)_>,
     <Movie id:2653344[http] title:_Game of Thrones: Season 2 - In Production, Belfast (2011) (V)_>,
     <Movie id:2667902[http] title:_Game of Thrones: Season 2 - In Production: Croatia (2012) (V)_>,
     <Movie id:2718250[http] title:_Game of Thrones Impressions (2012) (V)_>]
    
    
    In [120]:
    dex = ia.get_character('dexter')
    
    
    
    
    2014-05-06 07:27:29,584 CRITICAL [imdbpy] /usr/lib64/python2.7/site-packages/imdb/_exceptions.py:35: IMDbParserError exception raised; args: ('invalid characterID "dexter": invalid literal for int() with base 10: \'dexter\'',); kwds: {}
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/site-packages/imdb/parser/http/__init__.py", line 358, in _normalize_characterID
        return '%07d' % int(characterID)
    ValueError: invalid literal for int() with base 10: 'dexter'
    
    ---------------------------------------------------------------------------
    IMDbParserError                           Traceback (most recent call last)
    <ipython-input-120-567db1ee3bfa> in <module>()
    ----> 1 dex = ia.get_character('dexter')
    
    /usr/lib64/python2.7/site-packages/imdb/__init__.pyc in get_character(self, characterID, info, modFunct)
        510         If specified, modFunct will be the function used by the Character
        511         object when accessing its text fields (like 'biography')."""
    --> 512         characterID = self._normalize_characterID(characterID)
        513         characterID = self._get_real_characterID(characterID)
        514         character = Character.Character(characterID=characterID,
    
    /usr/lib64/python2.7/site-packages/imdb/parser/http/__init__.pyc in _normalize_characterID(self, characterID)
        359         except ValueError, e:
        360             raise IMDbParserError('invalid characterID "%s": %s' % \
    --> 361                     (characterID, e))
        362 
        363     def _normalize_companyID(self, companyID):
    
    IMDbParserError: invalid characterID "dexter": invalid literal for int() with base 10: 'dexter'
    
    
    In [119]:
    from imdb import IMDb
    ia = IMDb()
    
    the_matrix = ia.get_movie('0133093')
    print the_matrix['director']
    
    for person in ia.search_person('Mel Gibson'):
            print person.personID, person['name']
    
    
    
    
    [<Person id:0905152[http] name:_Wachowski, Andy_>, <Person id:0905154[http] name:_Wachowski, Lana_>]
    0000154 Mel Gibson
    2153167 Mel Gibson
    0317112 Mel Gibson
    2800055 Mel Gibson
    4798507 Mel A. Gibson
    3323885 Adam Taylor
    0000316 Mel Brooks
    0004959 Thomas Gibson
    0879085 Tyrese Gibson
    0316933 Deborah Gibson
    0002099 Henry Gibson
    0002072 Mel Ferrer
    0809321 Mel Smith
    0000305 Mel Blanc
    0004995 Mel Harris
    2706397 Leah Gibson
    0316945 Donal Gibson
    0868123 Mel Tormé
    0317159 Richard Gibson
    0735440 Mel Rodriguez
    
    
    
    In [93]:
    servlis
    
    
    
    
    Out[93]:
    [4,
     4,
     5,
     5,
     6,
     6,
     308287,
     308287,
     308287,
     308287,
     308287,
     308287,
     308287,
     308287,
     3135725,
     3135725,
     3135725,
     3135725,
     3135725,
     3445812,
     3445812,
     3445812,
     3445812,
     3445812,
     u'107.170.136.184',
     u'107.170.136.184',
     u'107.170.136.184',
     u'107.170.136.184',
     u'107.170.136.184',
     u'128.199.199.74',
     u'128.199.199.74',
     u'128.199.199.74',
     u'128.199.199.74',
     u'128.199.199.74',
     u'128.199.199.74',
     u'128.199.199.74',
     u'128.199.199.74',
     u'188.226.209.162',
     u'188.226.209.162',
     u'188.226.209.162',
     u'188.226.209.162',
     u'188.226.209.162',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'active',
     u'catgang',
     u'catgang',
     u'catgang',
     u'catgang',
     u'catgang',
     u'compohub',
     u'compohub',
     u'compohub',
     u'compohub',
     u'compohub',
     u'wcmckee',
     'wcmckee',
     'wcmckee',
     'wcmckee',
     u'wcmckee',
     'wcmckee',
     u'wcmckee',
     'wcmckee',
     u'wcmckee',
     'wcmckee',
     'wcmckee',
     'wcmckee',
     u'wcmckee',
     'wcmckee',
     'wcmckee',
     'wcmckee',
     u'wcmckee',
     'wcmckee',
     'wcmckee',
     'wcmckee',
     u'wcmckee',
     'wcmckee',
     u'wcmckee',
     'wcmckee',
     'wcmckee',
     'wcmckee']
    
    
    In [84]:
    olis = ['name', 'ip', 'status', 'id', 'user'] * 3
    
    
    
    In [85]:
    dictac = zip(olis, servlis)
    
    
    
    In [86]:
    dictac
    
    
    
    
    Out[86]:
    [('name', u'wcmckee'),
     ('ip', u'128.199.199.74'),
     ('status', u'active'),
     ('id', 308287),
     ('user', 'wcmckee'),
     ('name', u'catgang'),
     ('ip', u'188.226.209.162'),
     ('status', u'active'),
     ('id', 3135725),
     ('user', 'wcmckee'),
     ('name', u'compohub'),
     ('ip', u'107.170.136.184'),
     ('status', u'active'),
     ('id', 3445812),
     ('user', 'wcmckee')]

    when converting to a dict why does it only take the first part of dictac.

    
    
    In [73]:
    dicza = dict(dictac)
    
    
    
    In [74]:
    dicza
    
    
    
    
    Out[74]:
    {'id': 3445812,
     'ip': u'107.170.136.184',
     'name': u'compohub',
     'status': u'active',
     'user': 'wcmckee'}
    
    
    In [64]:
    jsndigoc = json.dumps(dicza)
    
    
    
    In [66]:
    jsndigoc
    
    
    
    
    Out[66]:
    '{"status": "active", "ip": "107.170.136.184", "user": "wcmckee", "name": "compohub", "id": 3445812}'
    
    
    In [67]:
    digocz = open('/home/will/Desktop/brobeur-static/feeds/digocserv.json', 'w')
    
    
    
    In [68]:
    digocz.write(jsndigoc)
    
    
    
    In [69]:
    digocz.close()
    
    
    
    In [42]:
    servlis
    
    
    
    
    Out[42]:
    [u'wcmckee',
     u'128.199.199.74',
     u'active',
     308287,
     'wcmckee',
     u'catgang',
     u'188.226.209.162',
     u'active',
     3135725,
     'wcmckee',
     u'compohub',
     u'107.170.136.184',
     u'active',
     3445812,
     'wcmckee']
    
    
    In [43]:
    dropo.ip_address
    
    
    
    
    Out[43]:
    u'128.199.199.74'
    
    
    In [44]:
    dropo.name
    
    
    
    
    Out[44]:
    u'wcmckee'
    
    
    In [45]:
    dropo
    
    
    
    
    Out[45]:
    <digitalocean.Droplet.Droplet at 0x31259d0>
    
    
    In [46]:
    droplis = []
    
    
    
    In [47]:
    iplis = []
    
    
    
    In [48]:
    dropdict = dict{}
    
    
    
    
      File "<ipython-input-48-07dc5ea10dbf>", line 1
        dropdict = dict{}
                       ^
    SyntaxError: invalid syntax
    
    
    
    In [49]:
    drstr = []
    
    
    
    In [50]:
    for dr in mydrop:
        print dr.ip_address
        droplis.append(dr.name)
        droplis.append(dr.ip_address)
        iplis.append(dr.ip_address)
        droplis.append(dr.status)
        print dr.status
        droplis.append(dr.region_id)
        print dr.region_id
        droplis.append(dr.ssh_key_ids)
        droplis.append(dr.id)
        droplis.append(dr)
        print dr.name
        print dr.ssh_key_ids
        print dr.id
        print dr.image_id
        print dr
        drstr.append(dr)
    
    
    
    
    128.199.199.74
    active
    6
    wcmckee
    None
    1331748
    308287
    <digitalocean.Droplet.Droplet object at 0x31259d0>
    188.226.209.162
    active
    5
    catgang
    None
    1496053
    3135725
    <digitalocean.Droplet.Droplet object at 0x3125a10>
    107.170.136.184
    active
    4
    compohub
    None
    1585671
    3445812
    <digitalocean.Droplet.Droplet object at 0x3125a90>
    
    
    
    In [51]:
    print droplis
    
    
    
    
    [u'wcmckee', u'128.199.199.74', u'active', 6, None, 1331748, <digitalocean.Droplet.Droplet object at 0x31259d0>, u'catgang', u'188.226.209.162', u'active', 5, None, 1496053, <digitalocean.Droplet.Droplet object at 0x3125a10>, u'compohub', u'107.170.136.184', u'active', 4, None, 1585671, <digitalocean.Droplet.Droplet object at 0x3125a90>]
    
    
    
    In [52]:
    print drstr
    
    
    
    
    [<digitalocean.Droplet.Droplet object at 0x31259d0>, <digitalocean.Droplet.Droplet object at 0x3125a10>, <digitalocean.Droplet.Droplet object at 0x3125a90>]
    
    
    
    In [53]:
    print iplis
    
    
    
    
    [u'128.199.199.74', u'188.226.209.162', u'107.170.136.184']
    
    
    
    In [54]:
    #!/usr/bin/python
     
    # All SSH libraries for Python are junk (2011-10-13).
    # Too low-level (libssh2), too buggy (paramiko), too complicated
    # (both), too poor in features (no use of the agent, for instance)
     
    # Here is the right solution today:
     
    import subprocess
    import sys
     
    HOST= '74.50.51.32'
    # Ports are handled in ~/.ssh/config since we use OpenSSH
    COMMAND="uname -a"
     
    ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],
    shell=False,
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE)
    result = ssh.stdout.readlines()
    if result == []:
        error = ssh.stderr.readlines()
        print >>sys.stderr, "ERROR: %s" % error
    else:
        print result
    
    
    
    
    ERROR: ['Connection closed by 74.50.51.32\r\n']
    
    
    
    In [55]:
    pwd
    
    
    
    
    Out[55]:
    u'/home/will/Desktop/artcontrol-api'
    
    
    In [40]:
    from crontab import CronTab
    
    system_cron   = CronTab()
    system_cron.new
    
    
    
    
    Out[40]:
    <bound method CronTab.new of <crontab.CronTab object at 0x2e44450>>
    
    
    In [50]:
    dropo.api_key
    
    
    
    
    Out[50]:
    '9898216d345df5b70ab943c5005c05df'
    
    
    In [51]:
    dropo.call_reponse
    
    
    
    In [52]:
    dropo.image_id
    
    
    
    
    Out[52]:
    308287
    
    
    In [53]:
    dropo.size_id
    
    
    
    
    Out[53]:
    66
    
    
    In [54]:
    dropo.events
    
    
    
    
    Out[54]:
    []
    
    
    In [55]:
    dropo.size_id
    
    
    
    
    Out[55]:
    66
    
    
    In [56]:
    domain = manager.get_all_domains
    
    
    
    In [57]:
    print domain
    
    
    
    
    <bound method Manager.get_all_domains of <digitalocean.Manager.Manager object at 0x2fdc410>>
    
    
    
    In [58]:
    domain.im_self
    
    
    
    
    Out[58]:
    <digitalocean.Manager.Manager at 0x2fdc410>
    
    
    In [59]:
    gimg = manager.get_global_images
    
    
    
    In [60]:
    gimg
    
    
    
    
    Out[60]:
    <bound method Manager.get_global_images of <digitalocean.Manager.Manager object at 0x2fdc410>>
    
    
    In [61]:
    list(gimg)
    
    
    
    
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-61-580ff6d51e82> in <module>()
    ----> 1 list(gimg)
    
    TypeError: 'instancemethod' object is not iterable
    
    
    In [96]:
    mysnap = manager.get_my_images()
    
    
    
    In [97]:
    my_droplets = manager.get_all_droplets()
    
    
    
    In [98]:
    for snap in mysnap:
        print snap.name
        print snap.id
    
    
    
    
    deb
    3266196
    deb
    3353451
    
    
    
    In [73]:
    my_droplets = manager.get_all_droplets()
    for droplet in my_droplets:
        print droplet
        droplet.power_off()
    
    
    
    
    <digitalocean.Droplet.Droplet object at 0x2fdcd90>
    <digitalocean.Droplet.Droplet object at 0x2fdcd50>
    
    
    
    In [46]:
    for droplet in my_droplets:
        print droplet
        droplet.power_on()
    
    
    
    
    <digitalocean.Droplet.Droplet object at 0x2e25990>
    <digitalocean.Droplet.Droplet object at 0x2e44ad0>
    <digitalocean.Droplet.Droplet object at 0x2e44fd0>
    <digitalocean.Droplet.Droplet object at 0x2e44d10>
    <digitalocean.Droplet.Droplet object at 0x2e44810>
    
    
    
    In [64]:
    for droplet in my_droplets:
        print droplet
        print droplet.name
    
    
    
    
    <digitalocean.Droplet.Droplet object at 0x2d45b10>
    wcmckee
    <digitalocean.Droplet.Droplet object at 0x2fdcbd0>
    catgang
    
    
    
    In [54]:
    dropo.power_off()
    
    
    
    In [74]:
    dropo.take_snapshot('deb')
    
    
    
    In [82]:
    dropo.status
    
    
    
    
    Out[82]:
    u'active'
    
    
    In [75]:
    dropo.rebuild()
    
    
    
    
    ---------------------------------------------------------------------------
    Exception                                 Traceback (most recent call last)
    <ipython-input-75-735d4c41b1e7> in <module>()
    ----> 1 dropo.rebuild()
    
    /usr/lib/python2.7/site-packages/digitalocean/Droplet.pyc in rebuild(self, image_id)
        112         if self.image_id and not image_id:
        113             image_id = self.image_id
    --> 114         self.__call_api("/rebuild/", {"image_id": image_id})
        115 
        116     def enable_backups(self):
    
    /usr/lib/python2.7/site-packages/digitalocean/Droplet.pyc in __call_api(self, path, params)
         31         if data['status'] != "OK":
         32             msg = [data[m] for m in ("message", "error_message", "status") if m in data][0]
    ---> 33             raise Exception(msg)
         34         #add the event to the object's event list.
         35         event_id = data.get(u'event_id',None)
    
    Exception: An invalid size was specified
    
    
    In [55]:
    droplet.client_id
    
    
    
    
    Out[55]:
    'a24a5636402aaf75d07b774d98591ea3'
    
    
    In [67]:
    myderp = manager.get_all_regions()
    
    
    
    In [68]:
    print myderp
    
    
    
    
    [<digitalocean.Region.Region object at 0x2fcf450>, <digitalocean.Region.Region object at 0x2fcf110>, <digitalocean.Region.Region object at 0x2fcf310>, <digitalocean.Region.Region object at 0x2fdced0>]
    
    
    
    In [69]:
    myderp
    
    
    
    
    Out[69]:
    [<digitalocean.Region.Region at 0x2fcf450>,
     <digitalocean.Region.Region at 0x2fcf110>,
     <digitalocean.Region.Region at 0x2fcf310>,
     <digitalocean.Region.Region at 0x2fdced0>]
    
    
    In [70]:
    for derp in myderp:
        print derp
        droplis.append(derp.name)
        droplis.append(derp.id)
        print derp.name
        print derp.id
    
    
    
    
    <digitalocean.Region.Region object at 0x2fcf450>
    San Francisco 1
    3
    <digitalocean.Region.Region object at 0x2fcf110>
    New York 2
    4
    <digitalocean.Region.Region object at 0x2fcf310>
    Amsterdam 2
    5
    <digitalocean.Region.Region object at 0x2fdced0>
    Singapore 1
    6
    
    
    
    In [72]:
    print droplis
    
    
    
    
    [u'wcmckee', u'128.199.199.74', u'active', 6, None, 1331748, <digitalocean.Droplet.Droplet object at 0x2fdca10>, u'catgang', u'188.226.209.162', u'active', 5, None, 1496053, <digitalocean.Droplet.Droplet object at 0x2fdc9d0>, u'San Francisco 1', 3, u'New York 2', 4, u'Amsterdam 2', 5, u'Singapore 1', 6]
    
    
    
    In [102]:
    dropserv = digitalocean.Droplet(client_id=digcli, api_key=apikey, name = 'uburub', region_id=5, image_id=3137635, size_id=66, backup_active=False)
    #dropserv.create()
    dropserv.Droplet
    
    
    
    In [ ]: