Lab 6 – Setting up Telescope

This lab was meant to get us to start working on the Telescope project in anticipation of release 0.3. We then had to use our link checker that we have been building up all year to interact with Telescope’s REST API.

Setup

First thing was to get Telescope setup. After reading through the documentation on how to get started I decided to go with the Docker route. I had a little bit of an issue using Docker for the first time. I was trying to run the first cmd in the documentation:

sudo systemctl start docker

but it kept telling me that sudo is not recognized as a command. I then decided just to try the next command and it started to do it’s thing.

docker-compose up --build redis elasticsearch

With Docker up and running I started the backend and then the frontend of telescope and I had a local version up and running. Onto the next step.

Talking with Telescope

Next, we had to figure out a way to interact with Telescopes REST API. We had to get the last 10 posts and then use our link checker to see if the links are valid. I was originally thinking of just writing some code that was independent of my link checker. It would create a file that I would then feed checkThatLink.

After thinking about it a bit deeper though I decided to just make a function inside checkThatLink. The function overwrites the file given and populates the variable with the last 10 posts from Telescope instead. I had some issues with reading the GET response object but after a little searching I found out I could convert it to json to better manipulate.

        posts = self.manager.request('GET', baseURL)
        posts = json.loads(posts.data.decode('utf-8'))

I had to make a change in my parse function because it wasn’t picking up the localhost url.

      if(url):
-            url = url.group(0)     
+            url = url.group(0)        
+        elif re.match('http://localhost:', line):
+            url = line     

There was a few other lines of code I made some changes to in order to get it working and you can check out the differences in this gist that I made.

Design a site like this with WordPress.com
Get started