Re: Fava setup on a publicly available server

2018-02-19 Thread Oon-Ee Ng
On Thu, Feb 8, 2018 at 4:50 PM, Stefano Zacchiroli  wrote:

> On Thu, Feb 08, 2018 at 12:08:40PM +0800, Oon-Ee Ng wrote:
> > Also I use fava's plugin capabilities to commit every time an edit
> > happens.
>
> Can you tell us more about this? It's the first time I hear about it,
> and it looks interesting to me. Also, given "git commit + git push" is
> probably a standard need for many people editing via Fava, would a
> "official" plugin for doing this be welcome?
>

Sorry, haven't been on for a couple of weeks. The plugin is dead simple,
and ONLY does commit, as handling push/pull would necessitate manual
intervention on conflicts, so I do that using a bash script instead.

The proper name is 'fava extension', and on any recent version of fava you
can find documentation about it on the Help page. It seems there's a recent
fava-plugins project to collect these[1].

My plugin looks like this:-

import os
import subprocess
from fava.ext import FavaExtensionBase
'''
Example hook for fava.

The hook add_transaction_git_commit will automatically add all files with
the
beancount suffix in fava's root folder and commit them with a message based
on
the transaction's narration, payee, and date.

To limit external dependencies, this uses the subprocess module (2.4+).
Please
read the documentation for that[1], especially if you're considering using
shell=True (probably a bad idea).

[1] - https://docs.python.org/2/library/subprocess.html
'''

class AutoCommit(FavaExtensionBase):
def _run(self, args):
cwd = os.path.dirname(self.ledger.beancount_file_path)
subprocess.call(args, cwd=cwd, stdout=subprocess.DEVNULL)

def after_write_source(self, path, _):
message = 'autocommit: file saved'
self._run(["git", "add", path])
self._run(["git", "commit", "-m", message])

def after_insert_metadata(self, *_):
message = 'autocommit: metadata added'
self._run(["git", "commit", "-am", message])

def after_insert_entry(self, entry):
message = 'autocommit:'
if entry.narration:
message += '"{}"'.format(entry.narration)
if entry.payee:
if message:
message += ' paid to "{}"'.format(entry.payee)
else:
message = 'Payment to "{}"'.format(entry.payee)
if message:
message += ' on {}'.format(entry.date)
else:
message += 'entry on {}'.format(entry.date)
self._run(["git", "commit", "-am", message])

I'm also planning a PR to extend fava's extensions capabilities[2] such
that they can modify the transactions themselves, but haven't had time to
get round to it (yet).

[1] - https://github.com/beancount/fava-plugins
[2] - https://github.com/beancount/fava/issues/564

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beancount+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAGQ70esxYhtkjkNgU5%2BOBjjh5%3Dgidn9xWGjKFuu4LoG_5ce1Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: (Eventual) native support for Windows?

2018-02-19 Thread Zhuoyun Wei
2018-02-17 07:22:11 Jeff Brantley :
> a) One has to install 3-4 GiB of compiler/build tools from Microsoft in order 
> to compile the C portions on the fly.
> This is workable, but ideally this would be distributed as a binary wheel (or 
> whatever, I'm no expert on python
> packaging).

I would like to share a successful example as a potential approach of
"native" Windows release of Beancount: 
https://github.com/borgbackup/borg/issues/440

BorgBackup is an excellent backup tool (try it out!) written in Python
and Cython. So compiling it in Windows is a headache, just like
Beancount. A contributor finally created an all-in-one Windows binary
installer for BorgBackup. The installation is self-contained and bundles
Cygwin, Python 3, and all the Python dependencies. It took ~100 MiB disk
space but it saves you from "polluting" your Windows with tons of
development tools.

I have been using the Windows BorgBackup release on my gaming PC for a
few months and it works well. You may consider creating a similar
Beancount Windows release as well.


-- 
Zhuoyun Wei

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beancount+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/20180219094606.GA10631%40herus.wzyboy.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature