Browse Source

Adding ascii_only and dd sparse file

Creating sparse files for loopback images can be done with the dd
command. The ascii_only strips all non-ascii characters out of a
string.
master
Nate Bohman 6 years ago
parent
commit
10205bd258
2 changed files with 16 additions and 0 deletions
  1. +3
    -0
      dd_create_sparse_file
  2. +13
    -0
      python_utils/ascii_only.py

+ 3
- 0
dd_create_sparse_file View File

# Create sparse.img with 100G (1K * 104857600) and
# actually transfer 0 K into it (count).
dd of=sparse.img bs=1k seek=104857600 count=0

+ 13
- 0
python_utils/ascii_only.py View File

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re

logger = logging.getLogger(__name__)

ascii_characters = [chr(i) for i in range(32,127)]
ascii_char_rgx = re.compile("{}".format(re.escape(ascii_characters)))


def ascii_only(incoming_string):
return control_char_rgx.sub("", incoming_string)

Loading…
Cancel
Save