<commit_before># -*- coding: utf-8 -*-

"""
Gets the current insync status

Configuration parameters:
    format: Display format to use *(default
        '{status}'
        )*

Format status string parameters:
    {status} Status of Insync

@author <NAME> <<EMAIL>>
Thanks to @author <NAME> <<EMAIL>> for the script that this is based on
@license BSD
"""

from time import time
import subprocess


class Py3status:
    # available configuration parameters
    cache_timeout = 1
    format = '{status}'

    def check_insync(self, i3s_output_list, i3s_config):
        status = str(subprocess.check_output(["/usr/bin/insync", "get_status"]))
        if len(status) > 5:
            status = status[2:-3]
        color = i3s_config.get('color_degraded', '')
        if status == "OFFLINE":
            color = i3s_config.get('color_bad', '')
        if status == "SHARE":
            color = i3s_config.get('color_good', '')
            status = "INSYNC"
        results = self.format.format(status=str(status))

        response = {
            'cached_until': time() + self.cache_timeout,
            'full_text': results,
            'color': color
        }
        return response

if __name__ == "__main__":
    """
    Test this module by calling it directly.
    """
    from time import sleep
    x = Py3status()
    config = {
        'color_bad': '#FF0000',
        'color_degraded': '#FFFF00',
        'color_good': '#00FF00'
    }
    while True:<commit_msg>Added the number of queued files to the sync status<commit_after># -*- coding: utf-8 -*-

"""
Gets the current insync status

Configuration parameters:
    format: Display format to use *(default
        '{status} {queued}'
        )*

Format status string parameters:
    {status} Status of Insync
    {queued} Number of files queued

@author <NAME> <<EMAIL>>
Thanks to @author <NAME> <<EMAIL>> for the script that this is based on
@license BSD
"""

from time import time
import subprocess


class Py3status:
    # available configuration parameters
    cache_timeout = 1
    format = '{status} {queued}'

    def check_insync(self, i3s_output_list, i3s_config):
        status = str(subprocess.check_output(["/usr/bin/insync", "get_status"]))
        if len(status) > 5:
            status = status[2:-3]
        color = i3s_config.get('color_degraded', '')
        if status == "OFFLINE":
            color = i3s_config.get('color_bad', '')
        if status == "SHARE":
            color = i3s_config.get('color_good', '')
            status = "INSYNC"

        queued = str(subprocess.check_output(["/usr/bin/insync", "get_sync_progress"]))
        queued = queued.split("\\n")
        if len(queued) > 2 and "queued" in queued[-2]:
            queued = queued[-2]
            queued = queued.split(" ")[0].replace("b'", "")
        else:
            queued = ""
        results = self.format.format(status=status, queued=queued)

        response = {
            'cached_until': time() + self.cache_timeout,
            'full_text': results,
            'color': color
        }
        return response

if __name__ == "__main__":
    """
    Test this module by calling it directly.
    """
    from time import sleep
    x = Py3status()
    config = {
        'color_bad': '#FF0000',
        'color_degraded': '#FFFF00',
        'color_good': '#00FF00'
    }
    while True:
{'fraction_non_alphanumeric': 0.13190092509698598, 'fraction_numerical': 0.01432408236347359, 'mean_word_length': 2.3824419778002017, 'pattern_counts': {'":': 6, '<': 15, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2105072', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1017, 'n_words': 277}