Reading Public Google Calendars using Python

There are many ways to access google calendars using python. You probably have already stumbled on the “Quick Start” page in the Google docs. This uses Oauth to authenticate requests and requires a human to approve the access.

But if you are reading from a public calendar, is all the necessary? No. You still need a developer key so that Google can keep track of your quota. But that is all you need.

Here is the solution from Stack Overflow. The trick is to use the developerKey keyword in the “build” function:

dev_Key = "Insert your dev key here"
service = build('calendar', 'v3', developerKey=dev_Key)
Advertisements

SSH Stops Working After Ubuntu Upgrade

I recently upgraded from 14.04 to 16.04. It went pretty smoothly, except some of my SSH connections stopped working. It turns out the the upgrade, automatically upgraded OpenSSL from version 6 to version 7 and version 7 no longer allows keys that it thinks are insecure.

To see what version you are running:

ssh -V

The big problem is the server I need to connect to is managed by a “Windows” guy who hates Linux. Getting him to update the key is going to take a while and I need to connect NOW.

The solution is at: http://www.openssh.com/legacy.html

I put this in my  ~/.ssh/config file:

Host XXX.XXX.XXX.XXX
    HostKeyAlgorithms +ssh-dss

It’s ugly, but it works.

Using the Ansible Find Command

The “find” command was added to Ansible in version 2. Here is how I used it to change the permissions on some log files:

- name: Get all log files in django manage.py dir
  find:
    paths: "{{ django_manage_path }}"
    patterns: "*.log"
    recurse: yes
  register: files_to_change
    

- name: Make sure Django log files in manage.py dir are owned by vagrant
  become: yes
  file: path={{ item.path }} owner=vagrant group=admin mode=0660
  with_items: "{{ files_to_change.files }}"

Ansible Could Not Find Templates After Migration from 1.9 to 2.5

I had a playbook that included a task from another role like this:

tasks:
  - include: roles/django/tasks/create_server_settings.yml

This include stopped working when I migrated from Ansible 1.9 to 2.5. The task used the “template” command and Ansible could not find the template. It looked in:

  • roles/django/tasks/templates/server_settings.py.j2
  • roles/django/tasks/server_settings.py.j2

I am using the recommended directory structure with the tasks and templates directories both at the same level in the directory tree, in this case:

  • roles/django/templates/server_settings.py.j2

Switching to the command:

 tasks:
  - include_tasks: roles/django/tasks/create_server_settings.yml

did NOT help.

The solution was to use this command:

tasks:
  - include_role:
      name: django
      tasks_from: create_server_settings

Fixing Hg Mistakes

Removing Pushes from Other Branches

I often create a branch by cloning. I do more involved or experimental things in the clone. While the parent branch is available to make small minor updates. As code in the branch progresses, I do commits. And every once in a while, by accident, I do a commit and push. This puts the experimental code in the main branch before its ready. To remove the pushed change set, cd into main and do:

hg strip -r REV