[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] SuperCollider sends email



Just marveling again at how much SuperCollider can do... I just
finished probably one of the more peculiar hacks attempted with SC,
namely:

- Parse comments on students' homework, stored in a specific list
format using org-mode in Emacs, and lay them out in a multilevel
identity dictionary.

- Link this to a table of students' IDs, names, e-mail addresses and grades.

- Using the trick at [1], send e-mail to each student containing a
form-letter preface, their numbers and the comments on each
assignment.

And I get a whole stream of:

trying 201110078: Zhao Yue... RESULT = 0
Sent mail successfully to Zhao Yue

trying 201110079: Li Sijie... RESULT = 0
Sent mail successfully to Li Sijie

trying 201110080: Zeng Xinyi... RESULT = 0
Sent mail successfully to Zeng Xinyi

p.sendStudentEmail = { |id, overrideAddress|
	var address, tempPath, tempFile, cond = Condition.new, return;
	if(thisThread.isKindOf(Routine).not) { Error("Must call
sendStudentEmail in a routine").throw };
	if(~students[id].notNil) {
		address = overrideAddress ?? { ~students[id][\email] };
		tempPath = Platform.defaultTempDir +/+ "%.txt".format(id);
		tempFile = File(tempPath, "w");
		if(tempFile.isOpen) {
			protect {
				p.commentsForStudent(id, tempFile);
			} { tempFile.close };
			"mail -s \"%\" % <%".format(~subject, address, tempPath.escapeChar($ ))
			.unixCmd({ |exit| return = exit; cond.unhang });
			cond.hang;
			File.delete(tempPath);
			if(return != 0) { Error("'mail' quit with exit code " ++ return).throw } {
				"Sent mail successfully to % <%>\n".format(~students[id][\name],
address).postln;
				0
			};
		} {
			Error("Could not open temp file " ++ tempPath).throw;
		};
	} { Error("No student with id %\n".format(id)).throw };
};

Blows my mind.

Thanks to all devs for making SC do more than just music!
hjh


-- 
James Harkins /// dewdrop world
jamshark70@xxxxxxxxxxxxxxxxx
http://www.dewdrop-world.net

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman

blog: http://www.dewdrop-world.net/words
audio clips: http://www.dewdrop-world.net/audio
more audio: http://soundcloud.com/dewdrop_world/tracks

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/