snose

Check-in [36abba8d1a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update README to reflect --file and other recent changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | master
Files: files | file ages | folders
SHA3-256: 36abba8d1ad2faf962fda82bdaef9a64fe6f51a08e3727ca5e6eaf771bee9123
User & Date: simon 2018-10-18 20:13:48
Context
2018-10-28
12:20
Those exits should have been sys.exit(). Whoops./ check-in: 3735e6b8ec user: simon tags: trunk, master
2018-10-18
20:13
Update README to reflect --file and other recent changes. check-in: 36abba8d1a user: simon tags: trunk, master
19:58
Explicitly set snose tag during sync

Because otherwise it gets removed - this is due to Simperium changes that
require everything to be set and since we don't set it here the tags get set to
a default of empty in simplenote.py now.

It would be nicer to not remove other tags if set, but I can live with this
just setting "snose". check-in: f26f676e5d user: simon tags: trunk, master

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to README.md.

13
14
15
16
17
18
19


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47




48


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
..
88
89
90
91
92
93
94
95
96
97
98
99

- Git seems a bit overkill
- I'm not really bothered about versioning, just synchronisation
- I just want to synchronise *some* files within a directory, not all of them (just imagine the `.gitignore`!)

## How to use



### In general - Authentication

Probably the best way is to store your credentials in `.netrc` with a `machine` of host "simple-note.appspot.com" and using the `login` and `password` entries. But you can also provide the username and password on the command line like so:

    python snose.py --username=me@email.com --password=mypassword

A token based approach would be nice, but for that I'd need to modify simplenote.py.

### Snort - Importing a new file

Take a file from the current directory and import into Simplenote as a new note:

    python snose.py --username=<me@email.com> --password=<mypassword> --snort=<filename.ext>
    
Note that snose works with with files in subdirectories as well, etc. The only issue I could see there would be cross-platform. I.e. path differences between Windows and \*Nix.

### Sniff - Importing an existing file

Take a file from the current directory and "match" it to an existing note within Simplenote

    python snose.py  --username=<me@email.com> --password=<mypassword> --sniff=<key> <filename.ext>

Where key is the id used by Simplenote to identify the note. So the best way to find this is to make sure the noted is tagged as "snose" in Simplenote and then you can use `snose.py --snot` to find the key.

### Sneeze - Export an existing file

Export a file from Simplenote to the current directory.





    python snose.py  --username=<me@email.com> --password=<mypassword> --sneeze=<key> <filename.ext>



### Sync - Synchronise files

Reads files in the `.snose` index file and synchronises them with Simplenote. 
    
	python snose.py  --username=<me@email.com> --password=<mypassword> --sync

You can pass the optional `--hanky` flag at the same time to perform a dry run; although the dry run can't indicate when merging will occur, only the ultimate direction of the update.

    python snose.py  --username=<me@email.com> --password=<mypassword> --sync --hanky


### Snot - List files available for synchronisation with SNose

Lists all files on Simplenote tagged "snose":

    python snose.py  --username=<me@email.com> --password=<mypassword> --snot

I could do with making this also list what is currently being synchronised based on the index. To make this most useful I suggest including the name of the file as a comment in the first line of the file. 

### Blow - Rollback to the previous version of a note

(Yeah, the command names are getting a bit rubbish now)

Rolls back a note both locally and remotely to the previous version. 

    python snose.py --username=<me@email.com> --password=<mypassword> --blow=<key>

The `blow` command requires Simplenote.py to be at [this commit](https://github.com/mrtazz/simplenote.py/commit/50e3de947b70fa5d9a7faee004ae20b169a1547d) at least.

	
## How it works

It's really quite simple (after all, I've done it), basically it creates a `.snose` file in the current directory that is json formatted. This is basically a Python dictionary that maps a filename (from the current directory) to a simplenote note (via the key) and also includes other simplenote data such as the modification date, version number and sync number (so it can figure out how to sync).

It then just implements the Simplenote recommendation from the api:

1. Iterates through each file stored in the `.snose` index.
................................................................................
3. Then attempts to update the remote version on Simplenote, but will merge the content if the remote has also changed. If merging occurs both the local and remote are updated.
4. Then checks for remote updates by comparing version numbers and updates local copies if necessary.


## To Do

- <s>Files in subdirectories, what happens there? I've just assumed all files in same directory as index</s> They work just fine! However, robust cross-platform support would be nice to handle/interpret file path differences between platforms.
- Using tags to contain filename: "filename:pants.txt" Some potential character limitations though? But an interesting idea for meta data.
- Add ability to "snort" multiple files
- List files currently being synchronised (read the .snose index). The `--snot` lists files tagged *snose* on Simplenote and the two might not necessarily be the same (i.e you've chose to sync some files on one machine and a different set on another).
- Write updated index file once after sync, instead of writing for each file change (although writing per file does have it's advantage from an error handling point of view)
 







>
>












|
|






|







>
>
>
>
|
>
>




|
|












|











|







 







|



<
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
..
96
97
98
99
100
101
102
103
104
105
106


- Git seems a bit overkill
- I'm not really bothered about versioning, just synchronisation
- I just want to synchronise *some* files within a directory, not all of them (just imagine the `.gitignore`!)

## How to use

Will probably work in Python 2 and 3 (and was initially developed under Python 2), but I've taken to using 3 as much as I can day to day so I won't be catching bugs for 2.

### In general - Authentication

Probably the best way is to store your credentials in `.netrc` with a `machine` of host "simple-note.appspot.com" and using the `login` and `password` entries. But you can also provide the username and password on the command line like so:

    python snose.py --username=me@email.com --password=mypassword

A token based approach would be nice, but for that I'd need to modify simplenote.py.

### Snort - Importing a new file

Take a file from the current directory and import into Simplenote as a new note:

    python snose.py --username=<me@email.com> --password=<mypassword> --snort --file=<filename.ext>

Note that snose works with with files in subdirectories as well, etc. The only issue I could see there would be cross-platform. I.e. path differences between Windows and \*Nix.

### Sniff - Importing an existing file

Take a file from the current directory and "match" it to an existing note within Simplenote

    python snose.py  --username=<me@email.com> --password=<mypassword> --sniff=<key> --file=<filename.ext>

Where key is the id used by Simplenote to identify the note. So the best way to find this is to make sure the noted is tagged as "snose" in Simplenote and then you can use `snose.py --snot` to find the key.

### Sneeze - Export an existing file

Export a file from Simplenote to the current directory.

    python snose.py  --username=<me@email.com> --password=<mypassword> --sneeze=<key> --file=<filename.ext>

Alternatively Snose can try to be clever: If you have `file:filename.txt` in the first three lines of the file (in a comment, etc) then you can do:

    python snose.py  --username=<me@email.com> --password=<mypassword> --sneeze=<key>

And it'll try and figure out the filename it should be exported as.

### Sync - Synchronise files

Reads files in the `.snose` index file and synchronises them with Simplenote. 

    python snose.py  --username=<me@email.com> --password=<mypassword> --sync

You can pass the optional `--hanky` flag at the same time to perform a dry run; although the dry run can't indicate when merging will occur, only the ultimate direction of the update.

    python snose.py  --username=<me@email.com> --password=<mypassword> --sync --hanky


### Snot - List files available for synchronisation with SNose

Lists all files on Simplenote tagged "snose":

    python snose.py  --username=<me@email.com> --password=<mypassword> --snot

I could do with making this also list what is currently being synchronised based on the index. To make this most useful I suggest including the name of the file as a comment in the first line of the file. It's pretty slow.

### Blow - Rollback to the previous version of a note

(Yeah, the command names are getting a bit rubbish now)

Rolls back a note both locally and remotely to the previous version. 

    python snose.py --username=<me@email.com> --password=<mypassword> --blow=<key>

The `blow` command requires Simplenote.py to be at [this commit](https://github.com/mrtazz/simplenote.py/commit/50e3de947b70fa5d9a7faee004ae20b169a1547d) at least.


## How it works

It's really quite simple (after all, I've done it), basically it creates a `.snose` file in the current directory that is json formatted. This is basically a Python dictionary that maps a filename (from the current directory) to a simplenote note (via the key) and also includes other simplenote data such as the modification date, version number and sync number (so it can figure out how to sync).

It then just implements the Simplenote recommendation from the api:

1. Iterates through each file stored in the `.snose` index.
................................................................................
3. Then attempts to update the remote version on Simplenote, but will merge the content if the remote has also changed. If merging occurs both the local and remote are updated.
4. Then checks for remote updates by comparing version numbers and updates local copies if necessary.


## To Do

- <s>Files in subdirectories, what happens there? I've just assumed all files in same directory as index</s> They work just fine! However, robust cross-platform support would be nice to handle/interpret file path differences between platforms.
- <s>Using tags to contain filename: "filename:pants.txt" Some potential character limitations though? But an interesting idea for meta data.</s> - I went for pulling it from a commented line in the file instead.
- Add ability to "snort" multiple files
- List files currently being synchronised (read the .snose index). The `--snot` lists files tagged *snose* on Simplenote and the two might not necessarily be the same (i.e you've chose to sync some files on one machine and a different set on another).
- Write updated index file once after sync, instead of writing for each file change (although writing per file does have it's advantage from an error handling point of view)