Browse Source

initial checkin

master
Georg Hopp 10 years ago
commit
f403a3cd1e
  1. 1
      .gitignore
  2. 46
      README.md
  3. 20
      getcal.py
  4. 42
      getcal.rb

1
.gitignore

@ -0,0 +1 @@
silpion.creds

46
README.md

@ -0,0 +1,46 @@
# getcal
A small script the retrieve calender entries from zimbra and format them for
the GNU calendar program.
## Synopsis
* ruby getcal.rb
* python getcal.py
## Description
There is a python and a ruby variant available. Both will write the generated
calendar entries to stdout.
## Requirements
Python or ruby.
## Dependencies
none
## Contributing
No contribution for now...
## License
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
## Author
Georg Hopp <georg@steffers.org>

20
getcal.py

@ -0,0 +1,20 @@
import requests
response = requests.get('url', auth=('user', 'password'))
current = {}
for line in response.text.splitlines():
if line[0:12] == 'BEGIN:VEVENT':
current = {'location': '', 'summary': '', 'start': ':00000000T080000'}
if line[0:7] == 'SUMMARY': current['summary'] = line[8:].strip()
if line[0:7] == 'DTSTART': current['start'] = line[8:].strip()
if line[0:8] == 'LOCATION': current['location'] = line[9:].strip()
if line[0:10] == 'END:VEVENT':
zone, timestr = current['start'].split(':')
sdate, stime = timestr.split('T')
hour, minute, sec = list(map(''.join, zip(*[iter(stime)]*2)))
line = "%s %s:%s (%s) %s" % (
sdate, hour, minute, current['location'], current['summary'])
print(line.encode('utf8'))
# vim: set ft=python et sta ts=4 sts=4 sw=4 tw=80:

42
getcal.rb

@ -0,0 +1,42 @@
require 'net/http'
uri = URI.parse("url")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
request.basic_auth("user", "password")
response = http.request(request)
all = []
current = {}
response.body.each_line do |line|
case
when line =~ /^BEGIN:VEVENT/
current = {}
when line =~ /^SUMMARY/
current[:summary] = line[line.index(':')+1..-1].strip #.gsub(/"/, '\\"')
when line =~ /^DTSTART/
current[:start] = line[line.index(':')+1..-1].strip
when line =~ /^LOCATION/
current[:location] = line[line.index(':')+1..-1].strip #.gsub(/"/, '\\"')
when line =~ /^END:VEVENT/
all << current
else
# just ignore everything else right now.
end
end
all.each do |c|
sdate, stime = c[:start].split('T')
hour = '08'
min = '00'
hour,min,sec = stime.scan(/../) unless stime.nil?
puts "#{sdate} #{hour}:#{min} (#{c[:location]}) #{c[:summary]}"
end
# vim: set ft=ruby et ts=2 sw=2:
Loading…
Cancel
Save